From ed5722666ba2b1e43b55f08ad0fdf1def0143f0e Mon Sep 17 00:00:00 2001 From: Pavel Raiskup Date: Tue, 27 Feb 2024 11:23:26 +0100 Subject: [PATCH] java: drop the old java code This was never released, and real code updates haven't been done for about 10 years. At the time of this commit, we are only getting GitHub's reports about security issues in vulnerable pom.xml dependencies, and random dependabot pull-requests. --- README | 4 +- java/.gitignore | 4 - java/AUTHORS | 1 - java/LICENSE | 202 ------------------ java/NOTICE | 4 - java/README | 1 - java/copr-api/pom.xml | 25 --- .../copr/client/BuildRequest.java | 101 --------- .../copr/client/BuildResult.java | 26 --- .../copr/client/CoprConfiguration.java | 58 ----- .../copr/client/CoprException.java | 35 --- .../copr/client/CoprService.java | 24 --- .../copr/client/CoprSession.java | 39 ---- .../copr/client/DetailRequest.java | 56 ----- .../copr/client/DetailResult.java | 35 --- .../copr/client/ListRequest.java | 43 ---- .../fedoraproject/copr/client/ListResult.java | 26 --- .../copr/client/PlaygroundListRequest.java | 26 --- .../copr/client/PlaygroundListResult.java | 26 --- .../fedoraproject/copr/client/ProjectId.java | 46 ---- .../copr/client/YumRepository.java | 38 ---- java/copr-cli/pom.xml | 48 ----- .../copr/client/cli/ConfigurationLoader.java | 101 --------- .../copr/client/cli/CoprCli.java | 52 ----- .../fedoraproject/copr/client/cli/Main.java | 27 --- java/copr-impl/pom.xml | 61 ------ .../copr/client/impl/BuildCommand.java | 88 -------- .../copr/client/impl/DefaultBuildResult.java | 47 ---- .../copr/client/impl/DefaultCoprService.java | 33 --- .../copr/client/impl/DefaultCoprSession.java | 95 -------- .../copr/client/impl/DefaultDetailResult.java | 80 ------- .../copr/client/impl/DefaultListResult.java | 41 ---- .../impl/DefaultPlaygroundListResult.java | 41 ---- .../copr/client/impl/DetailCommand.java | 77 ------- .../copr/client/impl/ListCommand.java | 74 ------- .../client/impl/PlaygroundListCommand.java | 71 ------ .../copr/client/impl/RpcCommand.java | 136 ------------ .../copr/client/impl/BuildTest.java | 85 -------- .../copr/client/impl/DetailTest.java | 121 ----------- .../copr/client/impl/HttpMock.java | 88 -------- .../copr/client/impl/ListTest.java | 141 ------------ .../copr/client/impl/PlaygroundListTest.java | 93 -------- .../copr/client/impl/RpcMock.java | 26 --- .../copr/client/impl/RpcTest.java | 78 ------- java/copr-impl/src/test/resources/build1.json | 5 - .../copr-impl/src/test/resources/detail1.json | 15 -- java/copr-impl/src/test/resources/fail.json | 1 - java/copr-impl/src/test/resources/list1.json | 15 -- java/copr-impl/src/test/resources/list2.json | 33 --- .../src/test/resources/playground.json | 41 ---- java/copr-java.spec | 47 ---- java/pom.xml | 47 ---- 52 files changed, 1 insertion(+), 2727 deletions(-) delete mode 100644 java/.gitignore delete mode 100644 java/AUTHORS delete mode 100644 java/LICENSE delete mode 100644 java/NOTICE delete mode 100644 java/README delete mode 100644 java/copr-api/pom.xml delete mode 100644 java/copr-api/src/main/java/org/fedoraproject/copr/client/BuildRequest.java delete mode 100644 java/copr-api/src/main/java/org/fedoraproject/copr/client/BuildResult.java delete mode 100644 java/copr-api/src/main/java/org/fedoraproject/copr/client/CoprConfiguration.java delete mode 100644 java/copr-api/src/main/java/org/fedoraproject/copr/client/CoprException.java delete mode 100644 java/copr-api/src/main/java/org/fedoraproject/copr/client/CoprService.java delete mode 100644 java/copr-api/src/main/java/org/fedoraproject/copr/client/CoprSession.java delete mode 100644 java/copr-api/src/main/java/org/fedoraproject/copr/client/DetailRequest.java delete mode 100644 java/copr-api/src/main/java/org/fedoraproject/copr/client/DetailResult.java delete mode 100644 java/copr-api/src/main/java/org/fedoraproject/copr/client/ListRequest.java delete mode 100644 java/copr-api/src/main/java/org/fedoraproject/copr/client/ListResult.java delete mode 100644 java/copr-api/src/main/java/org/fedoraproject/copr/client/PlaygroundListRequest.java delete mode 100644 java/copr-api/src/main/java/org/fedoraproject/copr/client/PlaygroundListResult.java delete mode 100644 java/copr-api/src/main/java/org/fedoraproject/copr/client/ProjectId.java delete mode 100644 java/copr-api/src/main/java/org/fedoraproject/copr/client/YumRepository.java delete mode 100644 java/copr-cli/pom.xml delete mode 100644 java/copr-cli/src/main/java/org/fedoraproject/copr/client/cli/ConfigurationLoader.java delete mode 100644 java/copr-cli/src/main/java/org/fedoraproject/copr/client/cli/CoprCli.java delete mode 100644 java/copr-cli/src/main/java/org/fedoraproject/copr/client/cli/Main.java delete mode 100644 java/copr-impl/pom.xml delete mode 100644 java/copr-impl/src/main/java/org/fedoraproject/copr/client/impl/BuildCommand.java delete mode 100644 java/copr-impl/src/main/java/org/fedoraproject/copr/client/impl/DefaultBuildResult.java delete mode 100644 java/copr-impl/src/main/java/org/fedoraproject/copr/client/impl/DefaultCoprService.java delete mode 100644 java/copr-impl/src/main/java/org/fedoraproject/copr/client/impl/DefaultCoprSession.java delete mode 100644 java/copr-impl/src/main/java/org/fedoraproject/copr/client/impl/DefaultDetailResult.java delete mode 100644 java/copr-impl/src/main/java/org/fedoraproject/copr/client/impl/DefaultListResult.java delete mode 100644 java/copr-impl/src/main/java/org/fedoraproject/copr/client/impl/DefaultPlaygroundListResult.java delete mode 100644 java/copr-impl/src/main/java/org/fedoraproject/copr/client/impl/DetailCommand.java delete mode 100644 java/copr-impl/src/main/java/org/fedoraproject/copr/client/impl/ListCommand.java delete mode 100644 java/copr-impl/src/main/java/org/fedoraproject/copr/client/impl/PlaygroundListCommand.java delete mode 100644 java/copr-impl/src/main/java/org/fedoraproject/copr/client/impl/RpcCommand.java delete mode 100644 java/copr-impl/src/test/java/org/fedoraproject/copr/client/impl/BuildTest.java delete mode 100644 java/copr-impl/src/test/java/org/fedoraproject/copr/client/impl/DetailTest.java delete mode 100644 java/copr-impl/src/test/java/org/fedoraproject/copr/client/impl/HttpMock.java delete mode 100644 java/copr-impl/src/test/java/org/fedoraproject/copr/client/impl/ListTest.java delete mode 100644 java/copr-impl/src/test/java/org/fedoraproject/copr/client/impl/PlaygroundListTest.java delete mode 100644 java/copr-impl/src/test/java/org/fedoraproject/copr/client/impl/RpcMock.java delete mode 100644 java/copr-impl/src/test/java/org/fedoraproject/copr/client/impl/RpcTest.java delete mode 100644 java/copr-impl/src/test/resources/build1.json delete mode 100644 java/copr-impl/src/test/resources/detail1.json delete mode 100644 java/copr-impl/src/test/resources/fail.json delete mode 100644 java/copr-impl/src/test/resources/list1.json delete mode 100644 java/copr-impl/src/test/resources/list2.json delete mode 100644 java/copr-impl/src/test/resources/playground.json delete mode 100644 java/copr-java.spec delete mode 100644 java/pom.xml diff --git a/README b/README index a48ace1d6..d05457219 100644 --- a/README +++ b/README @@ -20,6 +20,4 @@ Overview of use: - it retrieves the results and saves them into the results dir - it returns the build status and where to find the results to the front end -copr project is licensed under GPLv2+ (see LICENSE file for details), -except for Java parts (contents of java directory) which are licensed -under Apache License v2.0 (see java/LICENSE). +copr project is licensed under GPLv2+ (see LICENSE file for details) diff --git a/java/.gitignore b/java/.gitignore deleted file mode 100644 index f66baa433..000000000 --- a/java/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -.project -.classpath -.settings -target/ diff --git a/java/AUTHORS b/java/AUTHORS deleted file mode 100644 index c7f97d836..000000000 --- a/java/AUTHORS +++ /dev/null @@ -1 +0,0 @@ -Mikolaj Izdebski diff --git a/java/LICENSE b/java/LICENSE deleted file mode 100644 index d64569567..000000000 --- a/java/LICENSE +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/java/NOTICE b/java/NOTICE deleted file mode 100644 index ec3363763..000000000 --- a/java/NOTICE +++ /dev/null @@ -1,4 +0,0 @@ -Copyright (c) 2014 Red Hat, Inc. - -This product includes software developed by -Red Hat, Inc. (http://www.redhat.com/). diff --git a/java/README b/java/README deleted file mode 100644 index 5a8b5b6a9..000000000 --- a/java/README +++ /dev/null @@ -1 +0,0 @@ -Copr Client for Java diff --git a/java/copr-api/pom.xml b/java/copr-api/pom.xml deleted file mode 100644 index ee9edd58f..000000000 --- a/java/copr-api/pom.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - 4.0.0 - - org.fedoraproject.copr.client - copr-parent - 0.0.0-SNAPSHOT - - copr-api - Copr Client API - diff --git a/java/copr-api/src/main/java/org/fedoraproject/copr/client/BuildRequest.java b/java/copr-api/src/main/java/org/fedoraproject/copr/client/BuildRequest.java deleted file mode 100644 index 5f27953f1..000000000 --- a/java/copr-api/src/main/java/org/fedoraproject/copr/client/BuildRequest.java +++ /dev/null @@ -1,101 +0,0 @@ -/*- - * Copyright (c) 2014 Red Hat, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.fedoraproject.copr.client; - -import java.util.Collection; -import java.util.LinkedHashSet; -import java.util.Set; - -/** - * @author Mikolaj Izdebski - */ -public class BuildRequest -{ - private String userName; - - private String projectName; - - private final Set srpms = new LinkedHashSet<>(); - - private String memory; - - private String timeout; - - public BuildRequest() - { - } - - public BuildRequest( String userName, String projectName ) - { - this.userName = userName; - this.projectName = projectName; - } - - public String getUserName() - { - return userName; - } - - public void setUserName( String userName ) - { - this.userName = userName; - } - - public String getProjectName() - { - return projectName; - } - - public void setProjectName( String projectName ) - { - this.projectName = projectName; - } - - public Collection getSourceRpmList() - { - return srpms; - } - - public void addSourceRpm( String url ) - { - srpms.add( url ); - } - - public void removeSourceRpm( String url ) - { - srpms.remove( url ); - } - - public String getMemory() - { - return memory; - } - - public void setMemory( String memory ) - { - this.memory = memory; - } - - public String getTimeout() - { - return timeout; - } - - public void setTimeout( String timeout ) - { - this.timeout = timeout; - } -} diff --git a/java/copr-api/src/main/java/org/fedoraproject/copr/client/BuildResult.java b/java/copr-api/src/main/java/org/fedoraproject/copr/client/BuildResult.java deleted file mode 100644 index 5efa6e82c..000000000 --- a/java/copr-api/src/main/java/org/fedoraproject/copr/client/BuildResult.java +++ /dev/null @@ -1,26 +0,0 @@ -/*- - * Copyright (c) 2014 Red Hat, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.fedoraproject.copr.client; - -/** - * @author Mikolaj Izdebski - */ -public interface BuildResult -{ - String getMessage(); - - long getBuildId(); -} diff --git a/java/copr-api/src/main/java/org/fedoraproject/copr/client/CoprConfiguration.java b/java/copr-api/src/main/java/org/fedoraproject/copr/client/CoprConfiguration.java deleted file mode 100644 index 7bfe74178..000000000 --- a/java/copr-api/src/main/java/org/fedoraproject/copr/client/CoprConfiguration.java +++ /dev/null @@ -1,58 +0,0 @@ -/*- - * Copyright (c) 2014 Red Hat, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.fedoraproject.copr.client; - -/** - * @author Mikolaj Izdebski - */ -public class CoprConfiguration -{ - private String url; - - private String login; - - private String token; - - public String getUrl() - { - return url; - } - - public void setUrl( String url ) - { - this.url = url; - } - - public String getLogin() - { - return login; - } - - public void setLogin( String login ) - { - this.login = login; - } - - public String getToken() - { - return token; - } - - public void setToken( String token ) - { - this.token = token; - } -} diff --git a/java/copr-api/src/main/java/org/fedoraproject/copr/client/CoprException.java b/java/copr-api/src/main/java/org/fedoraproject/copr/client/CoprException.java deleted file mode 100644 index 59b6e1669..000000000 --- a/java/copr-api/src/main/java/org/fedoraproject/copr/client/CoprException.java +++ /dev/null @@ -1,35 +0,0 @@ -/*- - * Copyright (c) 2014 Red Hat, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.fedoraproject.copr.client; - -/** - * @author Mikolaj Izdebski - */ -public class CoprException - extends Exception -{ - private static final long serialVersionUID = 1L; - - public CoprException( String detail ) - { - super( detail ); - } - - public CoprException( String detail, Throwable cause ) - { - super( detail, cause ); - } -} diff --git a/java/copr-api/src/main/java/org/fedoraproject/copr/client/CoprService.java b/java/copr-api/src/main/java/org/fedoraproject/copr/client/CoprService.java deleted file mode 100644 index a13dff3a1..000000000 --- a/java/copr-api/src/main/java/org/fedoraproject/copr/client/CoprService.java +++ /dev/null @@ -1,24 +0,0 @@ -/*- - * Copyright (c) 2014 Red Hat, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.fedoraproject.copr.client; - -/** - * @author Mikolaj Izdebski - */ -public interface CoprService -{ - CoprSession newSession( CoprConfiguration configuration ); -} diff --git a/java/copr-api/src/main/java/org/fedoraproject/copr/client/CoprSession.java b/java/copr-api/src/main/java/org/fedoraproject/copr/client/CoprSession.java deleted file mode 100644 index 3346a3da8..000000000 --- a/java/copr-api/src/main/java/org/fedoraproject/copr/client/CoprSession.java +++ /dev/null @@ -1,39 +0,0 @@ -/*- - * Copyright (c) 2014 Red Hat, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.fedoraproject.copr.client; - -/** - * @author Mikolaj Izdebski - */ -public interface CoprSession - extends AutoCloseable -{ - ListResult list( ListRequest request ) - throws CoprException; - - PlaygroundListResult playgroundList( PlaygroundListRequest request ) - throws CoprException; - - DetailResult detail( DetailRequest request ) - throws CoprException; - - BuildResult build( BuildRequest request ) - throws CoprException; - - @Override - void close() - throws CoprException; -} diff --git a/java/copr-api/src/main/java/org/fedoraproject/copr/client/DetailRequest.java b/java/copr-api/src/main/java/org/fedoraproject/copr/client/DetailRequest.java deleted file mode 100644 index 652e28aff..000000000 --- a/java/copr-api/src/main/java/org/fedoraproject/copr/client/DetailRequest.java +++ /dev/null @@ -1,56 +0,0 @@ -/*- - * Copyright (c) 2014 Red Hat, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.fedoraproject.copr.client; - -/** - * @author Mikolaj Izdebski - */ -public class DetailRequest -{ - private String userName; - - private String projectName; - - public DetailRequest() - { - } - - public DetailRequest( String userName, String projectName ) - { - this.userName = userName; - this.projectName = projectName; - } - - public String getUserName() - { - return userName; - } - - public void setUserName( String userName ) - { - this.userName = userName; - } - - public String getProjectName() - { - return projectName; - } - - public void setProjectName( String projectName ) - { - this.projectName = projectName; - } -} diff --git a/java/copr-api/src/main/java/org/fedoraproject/copr/client/DetailResult.java b/java/copr-api/src/main/java/org/fedoraproject/copr/client/DetailResult.java deleted file mode 100644 index 22cfecd3b..000000000 --- a/java/copr-api/src/main/java/org/fedoraproject/copr/client/DetailResult.java +++ /dev/null @@ -1,35 +0,0 @@ -/*- - * Copyright (c) 2014 Red Hat, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.fedoraproject.copr.client; - -import java.util.Date; -import java.util.List; - -/** - * @author Mikolaj Izdebski - */ -public interface DetailResult -{ - public abstract Date getLastModified(); - - public abstract List getYumRepositories(); - - public abstract String getAdditionalRepos(); - - public abstract String getInstructions(); - - public abstract String getDescription(); -} diff --git a/java/copr-api/src/main/java/org/fedoraproject/copr/client/ListRequest.java b/java/copr-api/src/main/java/org/fedoraproject/copr/client/ListRequest.java deleted file mode 100644 index e57ee2121..000000000 --- a/java/copr-api/src/main/java/org/fedoraproject/copr/client/ListRequest.java +++ /dev/null @@ -1,43 +0,0 @@ -/*- - * Copyright (c) 2014 Red Hat, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.fedoraproject.copr.client; - -/** - * @author Mikolaj Izdebski - */ -public class ListRequest -{ - private String userName; - - public ListRequest() - { - } - - public ListRequest( String userName ) - { - this.userName = userName; - } - - public String getUserName() - { - return userName; - } - - public void setUserName( String userName ) - { - this.userName = userName; - } -} diff --git a/java/copr-api/src/main/java/org/fedoraproject/copr/client/ListResult.java b/java/copr-api/src/main/java/org/fedoraproject/copr/client/ListResult.java deleted file mode 100644 index cb1c4d287..000000000 --- a/java/copr-api/src/main/java/org/fedoraproject/copr/client/ListResult.java +++ /dev/null @@ -1,26 +0,0 @@ -/*- - * Copyright (c) 2014 Red Hat, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.fedoraproject.copr.client; - -import java.util.List; - -/** - * @author Mikolaj Izdebski - */ -public interface ListResult -{ - List getProjects(); -} diff --git a/java/copr-api/src/main/java/org/fedoraproject/copr/client/PlaygroundListRequest.java b/java/copr-api/src/main/java/org/fedoraproject/copr/client/PlaygroundListRequest.java deleted file mode 100644 index f0234f746..000000000 --- a/java/copr-api/src/main/java/org/fedoraproject/copr/client/PlaygroundListRequest.java +++ /dev/null @@ -1,26 +0,0 @@ -/*- - * Copyright (c) 2014 Red Hat, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.fedoraproject.copr.client; - -/** - * @author Mikolaj Izdebski - */ -public class PlaygroundListRequest -{ - public PlaygroundListRequest() - { - } -} diff --git a/java/copr-api/src/main/java/org/fedoraproject/copr/client/PlaygroundListResult.java b/java/copr-api/src/main/java/org/fedoraproject/copr/client/PlaygroundListResult.java deleted file mode 100644 index 630214deb..000000000 --- a/java/copr-api/src/main/java/org/fedoraproject/copr/client/PlaygroundListResult.java +++ /dev/null @@ -1,26 +0,0 @@ -/*- - * Copyright (c) 2014 Red Hat, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.fedoraproject.copr.client; - -import java.util.List; - -/** - * @author Mikolaj Izdebski - */ -public interface PlaygroundListResult -{ - List getProjects(); -} diff --git a/java/copr-api/src/main/java/org/fedoraproject/copr/client/ProjectId.java b/java/copr-api/src/main/java/org/fedoraproject/copr/client/ProjectId.java deleted file mode 100644 index a7d8a357f..000000000 --- a/java/copr-api/src/main/java/org/fedoraproject/copr/client/ProjectId.java +++ /dev/null @@ -1,46 +0,0 @@ -/*- - * Copyright (c) 2014 Red Hat, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.fedoraproject.copr.client; - -/** - * @author Mikolaj Izdebski - */ -public class ProjectId -{ - private String userName; - - private String projectName; - - public String getUserName() - { - return userName; - } - - public void setUserName( String userName ) - { - this.userName = userName; - } - - public String getProjectName() - { - return projectName; - } - - public void setProjectName( String projectName ) - { - this.projectName = projectName; - } -} diff --git a/java/copr-api/src/main/java/org/fedoraproject/copr/client/YumRepository.java b/java/copr-api/src/main/java/org/fedoraproject/copr/client/YumRepository.java deleted file mode 100644 index 44aacf303..000000000 --- a/java/copr-api/src/main/java/org/fedoraproject/copr/client/YumRepository.java +++ /dev/null @@ -1,38 +0,0 @@ -package org.fedoraproject.copr.client; - -public class YumRepository -{ - private String name; - - private String baseUrl; - - public YumRepository() - { - } - - public YumRepository( String name, String baseUrl ) - { - this.name = name; - this.baseUrl = baseUrl; - } - - public String getName() - { - return name; - } - - public void setName( String name ) - { - this.name = name; - } - - public String getBaseUrl() - { - return baseUrl; - } - - public void setBaseUrl( String baseUrl ) - { - this.baseUrl = baseUrl; - } -} diff --git a/java/copr-cli/pom.xml b/java/copr-cli/pom.xml deleted file mode 100644 index 61df795e4..000000000 --- a/java/copr-cli/pom.xml +++ /dev/null @@ -1,48 +0,0 @@ - - - 4.0.0 - - org.fedoraproject.copr.client - copr-parent - 0.0.0-SNAPSHOT - - copr-cli - Copr Command Line Client - - - ${project.groupId} - copr-api - ${project.version} - - - ${project.groupId} - copr-impl - ${project.version} - runtime - - - com.beust - jcommander - 1.35 - - - org.ini4j - ini4j - 0.5.4 - - - diff --git a/java/copr-cli/src/main/java/org/fedoraproject/copr/client/cli/ConfigurationLoader.java b/java/copr-cli/src/main/java/org/fedoraproject/copr/client/cli/ConfigurationLoader.java deleted file mode 100644 index 8029d5b49..000000000 --- a/java/copr-cli/src/main/java/org/fedoraproject/copr/client/cli/ConfigurationLoader.java +++ /dev/null @@ -1,101 +0,0 @@ -/*- - * Copyright (c) 2014 Red Hat, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.fedoraproject.copr.client.cli; - -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import org.fedoraproject.copr.client.CoprConfiguration; -import org.ini4j.Wini; - -/** - * @author Mikolaj Izdebski - */ -public class ConfigurationLoader -{ - private String getEvnDefault( String key, Object defaultValue ) - { - String value = System.getenv( key ); - if ( value == null || value.isEmpty() ) - return defaultValue.toString(); - - return value; - } - - private void addXdgBasePath( List configPaths, String location ) - { - Path base = Paths.get( location ); - if ( !base.isAbsolute() ) - return; - - Path path = base.resolve( "copr" ); - if ( Files.isRegularFile( path ) ) - configPaths.add( path ); - } - - public CoprConfiguration loadConfiguration( String customPath ) - { - List configPaths = new ArrayList<>(); - - if ( customPath != null ) - { - configPaths.add( Paths.get( customPath ) ); - } - else - { - Path xdgHome = Paths.get( getEvnDefault( "HOME", System.getProperty( "user.home" ) ) ); - addXdgBasePath( configPaths, getEvnDefault( "XDG_CONFIG_HOME", xdgHome.resolve( ".config" ) ) ); - - for ( String part : getEvnDefault( "XDG_CONFIG_DIRS", "/etc/xdg" ).split( ":" ) ) - addXdgBasePath( configPaths, part ); - - Collections.reverse( configPaths ); - } - - CoprConfiguration configuration = new CoprConfiguration(); - - for ( Path path : configPaths ) - { - try - { - Wini wini = new Wini( path.toFile() ); - - String url = wini.get( "copr-cli", "copr_url" ); - if ( url != null ) - configuration.setUrl( url ); - - String login = wini.get( "copr-cli", "login" ); - if ( login != null ) - configuration.setLogin( login ); - - String token = wini.get( "copr-cli", "token" ); - if ( token != null ) - configuration.setToken( token ); - } - catch ( IOException e ) - { - return null; - } - } - - return configuration; - } -} diff --git a/java/copr-cli/src/main/java/org/fedoraproject/copr/client/cli/CoprCli.java b/java/copr-cli/src/main/java/org/fedoraproject/copr/client/cli/CoprCli.java deleted file mode 100644 index 0a60f8f93..000000000 --- a/java/copr-cli/src/main/java/org/fedoraproject/copr/client/cli/CoprCli.java +++ /dev/null @@ -1,52 +0,0 @@ -/*- - * Copyright (c) 2014 Red Hat, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.fedoraproject.copr.client.cli; - -import java.util.ArrayList; -import java.util.List; - -import org.fedoraproject.copr.client.CoprConfiguration; - -import com.beust.jcommander.Parameter; - -/** - * @author Mikolaj Izdebski - */ -public class CoprCli -{ - @Parameter - private final List parameters = new ArrayList(); - - @Parameter( names = { "-h", "--help" }, description = "Show generic help" ) - private boolean help; - - @Parameter( names = { "--help-commands" }, description = "Show help about subcommands" ) - private boolean helpCommands; - - @Parameter( names = { "-c", "--config" }, description = "Select configuration file to use" ) - private String config; - - public void run() - { - ConfigurationLoader loader = new ConfigurationLoader(); - CoprConfiguration configuration = loader.loadConfiguration( config ); - if ( configuration == null ) - { - System.err.println( "Unable to load Copr configuration" ); - System.exit( 1 ); - } - } -} diff --git a/java/copr-cli/src/main/java/org/fedoraproject/copr/client/cli/Main.java b/java/copr-cli/src/main/java/org/fedoraproject/copr/client/cli/Main.java deleted file mode 100644 index 221ecaa0b..000000000 --- a/java/copr-cli/src/main/java/org/fedoraproject/copr/client/cli/Main.java +++ /dev/null @@ -1,27 +0,0 @@ -/*- - * Copyright (c) 2014 Red Hat, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.fedoraproject.copr.client.cli; - -/** - * @author Mikolaj Izdebski - */ -public class Main -{ - public static void main( String[] args ) - { - CoprCli cli = new CoprCli(); - } -} diff --git a/java/copr-impl/pom.xml b/java/copr-impl/pom.xml deleted file mode 100644 index 46266867e..000000000 --- a/java/copr-impl/pom.xml +++ /dev/null @@ -1,61 +0,0 @@ - - - 4.0.0 - - org.fedoraproject.copr.client - copr-parent - 0.0.0-SNAPSHOT - - copr-impl - - - ${project.groupId} - copr-api - ${project.version} - - - org.apache.httpcomponents - httpclient - 4.3.3 - - - com.google.code.gson - gson - 2.2.4 - - - junit - junit - 4.11 - test - - - org.easymock - easymock - 3.2 - test - - - org.apache.httpcomponents - httpclient - 4.3.3 - tests - test - - - Copr Implementation - diff --git a/java/copr-impl/src/main/java/org/fedoraproject/copr/client/impl/BuildCommand.java b/java/copr-impl/src/main/java/org/fedoraproject/copr/client/impl/BuildCommand.java deleted file mode 100644 index 5e1c7e7a5..000000000 --- a/java/copr-impl/src/main/java/org/fedoraproject/copr/client/impl/BuildCommand.java +++ /dev/null @@ -1,88 +0,0 @@ -/*- - * Copyright (c) 2014 Red Hat, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.fedoraproject.copr.client.impl; - -import java.util.LinkedHashMap; -import java.util.Map; - -import org.fedoraproject.copr.client.BuildRequest; -import org.fedoraproject.copr.client.BuildResult; - -import com.google.gson.JsonObject; - -/** - * @author Mikolaj Izdebski - */ -public class BuildCommand - extends RpcCommand -{ - private final BuildRequest request; - - public BuildCommand( BuildRequest request ) - { - this.request = request; - } - - @Override - protected boolean requiresAuthentication() - { - return true; - } - - @Override - protected String getCommandUrl() - { - return "/api/coprs/" + request.getUserName() + "/" + request.getProjectName() + "/new_build/"; - } - - @Override - protected Map getExtraArguments() - { - Map map = new LinkedHashMap<>(); - - StringBuilder sb = new StringBuilder(); - - for ( String url : request.getSourceRpmList() ) - { - if ( sb.length() > 0 ) - sb.append( ' ' ); - sb.append( url ); - } - - map.put( "pkgs", sb.toString() ); - - if ( request.getMemory() != null ) - { - map.put( "memory", request.getMemory() ); - } - - if ( request.getTimeout() != null ) - { - map.put( "timeout", request.getTimeout() ); - } - - return map; - } - - @Override - protected BuildResult parseResponse( JsonObject response ) - { - long buildId = response.get( "id" ).getAsLong(); - String message = response.get( "message" ).getAsString(); - - return new DefaultBuildResult( buildId, message ); - } -} diff --git a/java/copr-impl/src/main/java/org/fedoraproject/copr/client/impl/DefaultBuildResult.java b/java/copr-impl/src/main/java/org/fedoraproject/copr/client/impl/DefaultBuildResult.java deleted file mode 100644 index 491611821..000000000 --- a/java/copr-impl/src/main/java/org/fedoraproject/copr/client/impl/DefaultBuildResult.java +++ /dev/null @@ -1,47 +0,0 @@ -/*- - * Copyright (c) 2014 Red Hat, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.fedoraproject.copr.client.impl; - -import org.fedoraproject.copr.client.BuildResult; - -/** - * @author Mikolaj Izdebski - */ -public class DefaultBuildResult - implements BuildResult -{ - private final long buildId; - - private final String message; - - public DefaultBuildResult( long buildId, String message ) - { - this.buildId = buildId; - this.message = message; - } - - @Override - public long getBuildId() - { - return buildId; - } - - @Override - public String getMessage() - { - return message; - } -} diff --git a/java/copr-impl/src/main/java/org/fedoraproject/copr/client/impl/DefaultCoprService.java b/java/copr-impl/src/main/java/org/fedoraproject/copr/client/impl/DefaultCoprService.java deleted file mode 100644 index e6e6c708b..000000000 --- a/java/copr-impl/src/main/java/org/fedoraproject/copr/client/impl/DefaultCoprService.java +++ /dev/null @@ -1,33 +0,0 @@ -/*- - * Copyright (c) 2014 Red Hat, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.fedoraproject.copr.client.impl; - -import org.fedoraproject.copr.client.CoprConfiguration; -import org.fedoraproject.copr.client.CoprService; -import org.fedoraproject.copr.client.CoprSession; - -/** - * @author Mikolaj Izdebski - */ -public class DefaultCoprService - implements CoprService -{ - @Override - public CoprSession newSession( CoprConfiguration configuration ) - { - return new DefaultCoprSession( configuration ); - } -} diff --git a/java/copr-impl/src/main/java/org/fedoraproject/copr/client/impl/DefaultCoprSession.java b/java/copr-impl/src/main/java/org/fedoraproject/copr/client/impl/DefaultCoprSession.java deleted file mode 100644 index 59ec0398a..000000000 --- a/java/copr-impl/src/main/java/org/fedoraproject/copr/client/impl/DefaultCoprSession.java +++ /dev/null @@ -1,95 +0,0 @@ -/*- - * Copyright (c) 2014 Red Hat, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.fedoraproject.copr.client.impl; - -import org.apache.http.client.HttpClient; -import org.apache.http.impl.client.HttpClients; -import org.fedoraproject.copr.client.BuildRequest; -import org.fedoraproject.copr.client.BuildResult; -import org.fedoraproject.copr.client.CoprConfiguration; -import org.fedoraproject.copr.client.CoprException; -import org.fedoraproject.copr.client.CoprSession; -import org.fedoraproject.copr.client.DetailRequest; -import org.fedoraproject.copr.client.DetailResult; -import org.fedoraproject.copr.client.ListRequest; -import org.fedoraproject.copr.client.ListResult; -import org.fedoraproject.copr.client.PlaygroundListRequest; -import org.fedoraproject.copr.client.PlaygroundListResult; - -/** - * @author Mikolaj Izdebski - */ -public class DefaultCoprSession - implements CoprSession -{ - private final CoprConfiguration configuration; - - private final HttpClient client; - - public DefaultCoprSession( CoprConfiguration configuration ) - { - this.configuration = configuration; - client = HttpClients.createDefault(); - } - - public HttpClient getClient() - { - return client; - } - - public CoprConfiguration getConfiguration() - { - return configuration; - } - - @Override - public void close() - throws CoprException - { - } - - @Override - public ListResult list( ListRequest request ) - throws CoprException - { - ListCommand command = new ListCommand( request ); - return command.execute( this ); - } - - @Override - public PlaygroundListResult playgroundList( PlaygroundListRequest request ) - throws CoprException - { - PlaygroundListCommand command = new PlaygroundListCommand( request ); - return command.execute( this ); - } - - @Override - public DetailResult detail( DetailRequest request ) - throws CoprException - { - DetailCommand command = new DetailCommand( request ); - return command.execute( this ); - } - - @Override - public BuildResult build( BuildRequest request ) - throws CoprException - { - BuildCommand command = new BuildCommand( request ); - return command.execute( this ); - } -} diff --git a/java/copr-impl/src/main/java/org/fedoraproject/copr/client/impl/DefaultDetailResult.java b/java/copr-impl/src/main/java/org/fedoraproject/copr/client/impl/DefaultDetailResult.java deleted file mode 100644 index 7aa4498b0..000000000 --- a/java/copr-impl/src/main/java/org/fedoraproject/copr/client/impl/DefaultDetailResult.java +++ /dev/null @@ -1,80 +0,0 @@ -/*- - * Copyright (c) 2014 Red Hat, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.fedoraproject.copr.client.impl; - -import java.util.Collections; -import java.util.Date; -import java.util.List; - -import org.fedoraproject.copr.client.DetailResult; -import org.fedoraproject.copr.client.YumRepository; - -/** - * @author Mikolaj Izdebski - */ -public class DefaultDetailResult - implements DetailResult -{ - private final String description; - - private final String instructions; - - private final String additionalRepos; - - private final List yumRepositories; - - private final Date lastModified; - - public DefaultDetailResult( String description, String instructions, String additionalRepos, - List yumRepositories, long lastModified ) - { - this.description = description; - this.instructions = instructions; - this.additionalRepos = additionalRepos; - this.yumRepositories = Collections.unmodifiableList( yumRepositories ); - this.lastModified = new Date( lastModified ); - } - - @Override - public String getDescription() - { - return description; - } - - @Override - public String getInstructions() - { - return instructions; - } - - @Override - public String getAdditionalRepos() - { - return additionalRepos; - } - - @Override - public List getYumRepositories() - { - return yumRepositories; - } - - @Override - public Date getLastModified() - { - return lastModified; - } -} diff --git a/java/copr-impl/src/main/java/org/fedoraproject/copr/client/impl/DefaultListResult.java b/java/copr-impl/src/main/java/org/fedoraproject/copr/client/impl/DefaultListResult.java deleted file mode 100644 index 1c4f64be6..000000000 --- a/java/copr-impl/src/main/java/org/fedoraproject/copr/client/impl/DefaultListResult.java +++ /dev/null @@ -1,41 +0,0 @@ -/*- - * Copyright (c) 2014 Red Hat, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.fedoraproject.copr.client.impl; - -import java.util.Collections; -import java.util.List; - -import org.fedoraproject.copr.client.ListResult; -import org.fedoraproject.copr.client.ProjectId; - -/** - * @author Mikolaj Izdebski - */ -public class DefaultListResult - implements ListResult -{ - private final List projects; - - public DefaultListResult( List projects ) - { - this.projects = Collections.unmodifiableList( projects ); - } - - public List getProjects() - { - return projects; - } -} diff --git a/java/copr-impl/src/main/java/org/fedoraproject/copr/client/impl/DefaultPlaygroundListResult.java b/java/copr-impl/src/main/java/org/fedoraproject/copr/client/impl/DefaultPlaygroundListResult.java deleted file mode 100644 index 54277ce39..000000000 --- a/java/copr-impl/src/main/java/org/fedoraproject/copr/client/impl/DefaultPlaygroundListResult.java +++ /dev/null @@ -1,41 +0,0 @@ -/*- - * Copyright (c) 2014 Red Hat, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.fedoraproject.copr.client.impl; - -import java.util.Collections; -import java.util.List; - -import org.fedoraproject.copr.client.PlaygroundListResult; -import org.fedoraproject.copr.client.ProjectId; - -/** - * @author Mikolaj Izdebski - */ -public class DefaultPlaygroundListResult - implements PlaygroundListResult -{ - private final List projects; - - public DefaultPlaygroundListResult( List projects ) - { - this.projects = Collections.unmodifiableList( projects ); - } - - public List getProjects() - { - return projects; - } -} diff --git a/java/copr-impl/src/main/java/org/fedoraproject/copr/client/impl/DetailCommand.java b/java/copr-impl/src/main/java/org/fedoraproject/copr/client/impl/DetailCommand.java deleted file mode 100644 index 73b0a7fde..000000000 --- a/java/copr-impl/src/main/java/org/fedoraproject/copr/client/impl/DetailCommand.java +++ /dev/null @@ -1,77 +0,0 @@ -/*- - * Copyright (c) 2014 Red Hat, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.fedoraproject.copr.client.impl; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; - -import org.fedoraproject.copr.client.DetailRequest; -import org.fedoraproject.copr.client.DetailResult; -import org.fedoraproject.copr.client.YumRepository; - -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; - -/** - * @author Mikolaj Izdebski - */ -public class DetailCommand - extends RpcCommand -{ - private final DetailRequest request; - - public DetailCommand( DetailRequest request ) - { - this.request = request; - } - - @Override - protected String getCommandUrl() - { - return "/api/coprs/" + request.getUserName() + "/" + request.getProjectName() + "/detail/"; - } - - @Override - protected Map getExtraArguments() - { - return null; - } - - @Override - protected DetailResult parseResponse( JsonObject response ) - { - JsonObject detail = response.get( "detail" ).getAsJsonObject(); - - String additionalRepos = detail.get( "additional_repos" ).getAsString(); - String description = detail.get( "description" ).getAsString(); - String instructions = detail.get( "instructions" ).getAsString(); - long lastModified = detail.get( "last_modified" ).getAsLong(); - - JsonObject repos = detail.get( "yum_repos" ).getAsJsonObject(); - List yumRepos = new ArrayList<>(); - for ( Entry entry : repos.entrySet() ) - { - String name = entry.getKey(); - String baseUrl = entry.getValue().getAsString(); - YumRepository repo = new YumRepository( name, baseUrl ); - yumRepos.add( repo ); - } - - return new DefaultDetailResult( description, instructions, additionalRepos, yumRepos, lastModified ); - } -} diff --git a/java/copr-impl/src/main/java/org/fedoraproject/copr/client/impl/ListCommand.java b/java/copr-impl/src/main/java/org/fedoraproject/copr/client/impl/ListCommand.java deleted file mode 100644 index 02848692f..000000000 --- a/java/copr-impl/src/main/java/org/fedoraproject/copr/client/impl/ListCommand.java +++ /dev/null @@ -1,74 +0,0 @@ -/*- - * Copyright (c) 2014 Red Hat, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.fedoraproject.copr.client.impl; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import org.fedoraproject.copr.client.ListRequest; -import org.fedoraproject.copr.client.ListResult; -import org.fedoraproject.copr.client.ProjectId; - -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; - -/** - * @author Mikolaj Izdebski - */ -public class ListCommand - extends RpcCommand -{ - private final ListRequest request; - - public ListCommand( ListRequest request ) - { - this.request = request; - } - - @Override - protected String getCommandUrl() - { - return "/api/coprs/" + request.getUserName() + "/"; - } - - @Override - protected Map getExtraArguments() - { - return null; - } - - @Override - protected ListResult parseResponse( JsonObject response ) - { - List projects = new ArrayList<>(); - - JsonArray repos = response.get( "repos" ).getAsJsonArray(); - for ( JsonElement element : repos ) - { - JsonObject repo = element.getAsJsonObject(); - - ProjectId id = new ProjectId(); - id.setUserName( request.getUserName() ); - id.setProjectName( repo.get( "name" ).getAsString() ); - - projects.add( id ); - } - - return new DefaultListResult( projects ); - } -} diff --git a/java/copr-impl/src/main/java/org/fedoraproject/copr/client/impl/PlaygroundListCommand.java b/java/copr-impl/src/main/java/org/fedoraproject/copr/client/impl/PlaygroundListCommand.java deleted file mode 100644 index 83550580c..000000000 --- a/java/copr-impl/src/main/java/org/fedoraproject/copr/client/impl/PlaygroundListCommand.java +++ /dev/null @@ -1,71 +0,0 @@ -/*- - * Copyright (c) 2014 Red Hat, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.fedoraproject.copr.client.impl; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import org.fedoraproject.copr.client.PlaygroundListRequest; -import org.fedoraproject.copr.client.PlaygroundListResult; -import org.fedoraproject.copr.client.ProjectId; - -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; - -/** - * @author Mikolaj Izdebski - */ -public class PlaygroundListCommand - extends RpcCommand -{ - public PlaygroundListCommand( PlaygroundListRequest request ) - { - } - - @Override - protected String getCommandUrl() - { - return "/api/playground/list/"; - } - - @Override - protected Map getExtraArguments() - { - return null; - } - - @Override - protected PlaygroundListResult parseResponse( JsonObject response ) - { - List projects = new ArrayList<>(); - - JsonArray repos = response.get( "repos" ).getAsJsonArray(); - for ( JsonElement element : repos ) - { - JsonObject repo = element.getAsJsonObject(); - - ProjectId id = new ProjectId(); - id.setUserName( repo.get( "username" ).getAsString() ); - id.setProjectName( repo.get( "coprname" ).getAsString() ); - - projects.add( id ); - } - - return new DefaultPlaygroundListResult( projects ); - } -} diff --git a/java/copr-impl/src/main/java/org/fedoraproject/copr/client/impl/RpcCommand.java b/java/copr-impl/src/main/java/org/fedoraproject/copr/client/impl/RpcCommand.java deleted file mode 100644 index 63f1206f5..000000000 --- a/java/copr-impl/src/main/java/org/fedoraproject/copr/client/impl/RpcCommand.java +++ /dev/null @@ -1,136 +0,0 @@ -/*- - * Copyright (c) 2014 Red Hat, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.fedoraproject.copr.client.impl; - -import static org.apache.http.entity.ContentType.APPLICATION_JSON; - -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.Reader; -import java.net.HttpURLConnection; -import java.nio.charset.StandardCharsets; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; - -import javax.xml.bind.DatatypeConverter; - -import org.apache.http.HttpResponse; -import org.apache.http.NameValuePair; -import org.apache.http.client.HttpClient; -import org.apache.http.client.entity.UrlEncodedFormEntity; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.client.methods.HttpUriRequest; -import org.apache.http.message.BasicNameValuePair; -import org.fedoraproject.copr.client.CoprException; - -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; - -/** - * @author Mikolaj Izdebski - */ -public abstract class RpcCommand -{ - protected abstract String getCommandUrl(); - - protected abstract Map getExtraArguments(); - - protected abstract T parseResponse( JsonObject response ); - - protected boolean requiresAuthentication() - { - return false; - } - - public T execute( DefaultCoprSession session ) - throws CoprException - { - try - { - HttpClient client = session.getClient(); - - String baseUrl = session.getConfiguration().getUrl(); - String commandUrl = getCommandUrl(); - String url = baseUrl + commandUrl; - - Map extraArgs = getExtraArguments(); - HttpUriRequest request; - if ( extraArgs == null ) - { - request = new HttpGet( url ); - } - else - { - HttpPost post = new HttpPost( url ); - request = post; - - List nameValuePairs = new ArrayList( 2 ); - for ( Entry entry : extraArgs.entrySet() ) - { - nameValuePairs.add( new BasicNameValuePair( entry.getKey(), entry.getValue() ) ); - } - post.setEntity( new UrlEncodedFormEntity( nameValuePairs ) ); - } - - if ( requiresAuthentication() ) - { - String login = session.getConfiguration().getLogin(); - if ( login == null || login.isEmpty() ) - throw new CoprException( "Authentification is required to perform this command " - + "but no login was provided in configuration" ); - - String token = session.getConfiguration().getToken(); - if ( token == null || token.isEmpty() ) - throw new CoprException( "Authentification is required to perform this command " - + "but no login was provided in configuration" ); - - String auth = login + ":" + token; - String encodedAuth = DatatypeConverter.printBase64Binary( auth.getBytes( StandardCharsets.UTF_8 ) ); - request.setHeader( "Authorization", "Basic " + encodedAuth ); - } - - request.addHeader( "Accept", APPLICATION_JSON.getMimeType() ); - - HttpResponse response = client.execute( request ); - int returnCode = response.getStatusLine().getStatusCode(); - - if ( returnCode != HttpURLConnection.HTTP_OK ) - { - throw new CoprException( "Copr RPC failed: HTTP " + returnCode + " " - + response.getStatusLine().getReasonPhrase() ); - } - - Reader responseReader = new InputStreamReader( response.getEntity().getContent() ); - JsonParser parser = new JsonParser(); - JsonObject rpcResponse = parser.parse( responseReader ).getAsJsonObject(); - - String rpcStatus = rpcResponse.get( "output" ).getAsString(); - if ( !rpcStatus.equals( "ok" ) ) - { - throw new CoprException( "Copr RPC returned failure response" ); - } - - return parseResponse( rpcResponse ); - } - catch ( IOException e ) - { - throw new CoprException( "Failed to call remote Copr procedure", e ); - } - } -} diff --git a/java/copr-impl/src/test/java/org/fedoraproject/copr/client/impl/BuildTest.java b/java/copr-impl/src/test/java/org/fedoraproject/copr/client/impl/BuildTest.java deleted file mode 100644 index 1e97df988..000000000 --- a/java/copr-impl/src/test/java/org/fedoraproject/copr/client/impl/BuildTest.java +++ /dev/null @@ -1,85 +0,0 @@ -/*- - * Copyright (c) 2014 Red Hat, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.fedoraproject.copr.client.impl; - -import static org.easymock.EasyMock.expect; -import static org.easymock.EasyMock.replay; -import static org.easymock.EasyMock.verify; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; - -import org.easymock.EasyMockRunner; -import org.fedoraproject.copr.client.BuildRequest; -import org.fedoraproject.copr.client.BuildResult; -import org.fedoraproject.copr.client.CoprConfiguration; -import org.fedoraproject.copr.client.CoprException; -import org.junit.Test; -import org.junit.runner.RunWith; - -@RunWith( EasyMockRunner.class ) -public class BuildTest - extends RpcTest -{ - @Override - protected CoprConfiguration getConfiguration() - { - CoprConfiguration config = super.getConfiguration(); - - config.setLogin( "test-login" ); - config.setToken( "p4s5w0rd" ); - - return config; - } - - @Test - public void testBuild() - throws Exception - { - expect( mock.post( "/api/coprs/john/toy/new_build/" ) ).andReturn( "build1" ); - replay( mock ); - - BuildRequest request = new BuildRequest( "john", "toy" ); - - BuildResult result = session.build( request ); - - verify( mock ); - assertEquals( 1, server.getAcceptedConnectionCount() ); - - assertEquals( "Build was added to log4j.", result.getMessage() ); - assertEquals( 5, result.getBuildId() ); - } - - @Test - public void testBuildFail() - throws Exception - { - expect( mock.post( "/api/coprs/john/toy/new_build/" ) ).andReturn( "fail" ); - replay( mock ); - - BuildRequest request = new BuildRequest( "john", "toy" ); - - try - { - session.build( request ); - fail(); - } - catch ( CoprException e ) - { - verify( mock ); - assertEquals( 1, server.getAcceptedConnectionCount() ); - } - } -} diff --git a/java/copr-impl/src/test/java/org/fedoraproject/copr/client/impl/DetailTest.java b/java/copr-impl/src/test/java/org/fedoraproject/copr/client/impl/DetailTest.java deleted file mode 100644 index a669e909c..000000000 --- a/java/copr-impl/src/test/java/org/fedoraproject/copr/client/impl/DetailTest.java +++ /dev/null @@ -1,121 +0,0 @@ -/*- - * Copyright (c) 2014 Red Hat, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.fedoraproject.copr.client.impl; - -import static org.easymock.EasyMock.expect; -import static org.easymock.EasyMock.replay; -import static org.easymock.EasyMock.verify; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.util.Date; -import java.util.Iterator; - -import org.easymock.EasyMockRunner; -import org.fedoraproject.copr.client.CoprException; -import org.fedoraproject.copr.client.DetailRequest; -import org.fedoraproject.copr.client.DetailResult; -import org.fedoraproject.copr.client.YumRepository; -import org.junit.Test; -import org.junit.runner.RunWith; - -@RunWith( EasyMockRunner.class ) -public class DetailTest - extends RpcTest -{ - @Test - public void testApiFailure() - throws Exception - { - expect( mock.get( "/api/coprs/mizdebsk/override/detail/" ) ).andReturn( "fail" ); - replay( mock ); - - DetailRequest request = new DetailRequest( "mizdebsk", "override" ); - - try - { - session.detail( request ); - fail(); - } - catch ( CoprException e ) - { - verify( mock ); - assertEquals( 1, server.getAcceptedConnectionCount() ); - } - } - - @Test - public void test404() - throws Exception - { - expect( mock.get( "/api/coprs/mizdebsk/override/detail/" ) ).andReturn( null ); - replay( mock ); - - DetailRequest request = new DetailRequest( "mizdebsk", "override" ); - - try - { - session.detail( request ); - fail(); - } - catch ( CoprException e ) - { - verify( mock ); - assertEquals( 1, server.getAcceptedConnectionCount() ); - - assertTrue( e.getMessage().contains( "404 Not Found" ) ); - } - } - - @Test - public void testSingleRepo() - throws Exception - { - expect( mock.get( "/api/coprs/mizdebsk/override/detail/" ) ).andReturn( "detail1" ); - replay( mock ); - - DetailRequest request = new DetailRequest( "mizdebsk", "override" ); - DetailResult result = session.detail( request ); - - verify( mock ); - assertEquals( 1, server.getAcceptedConnectionCount() ); - - assertNotNull( result ); - assertEquals( "Fixed or tweaked versions of some Fedora packages, for personal use.", result.getDescription() ); - assertEquals( "Nothing complicated, really...", result.getInstructions() ); - assertEquals( "", result.getAdditionalRepos() ); - assertEquals( new Date( 1407916203 ), result.getLastModified() ); - - Iterator it = result.getYumRepositories().iterator(); - assertTrue( it.hasNext() ); - YumRepository repo1 = it.next(); - assertEquals( "fedora-20-x86_64", repo1.getName() ); - assertEquals( "http://copr-be.cloud.fedoraproject.org/results/mizdebsk/override/fedora-20-x86_64/", - repo1.getBaseUrl() ); - YumRepository repo2 = it.next(); - assertEquals( "fedora-21-x86_64", repo2.getName() ); - assertEquals( "http://copr-be.cloud.fedoraproject.org/results/mizdebsk/override/fedora-21-x86_64/", - repo2.getBaseUrl() ); - YumRepository repo3 = it.next(); - assertEquals( "fedora-rawhide-x86_64", repo3.getName() ); - assertEquals( "http://copr-be.cloud.fedoraproject.org/results/mizdebsk/override/fedora-rawhide-x86_64/", - repo3.getBaseUrl() ); - assertFalse( it.hasNext() ); - } -} diff --git a/java/copr-impl/src/test/java/org/fedoraproject/copr/client/impl/HttpMock.java b/java/copr-impl/src/test/java/org/fedoraproject/copr/client/impl/HttpMock.java deleted file mode 100644 index 59480f018..000000000 --- a/java/copr-impl/src/test/java/org/fedoraproject/copr/client/impl/HttpMock.java +++ /dev/null @@ -1,88 +0,0 @@ -/*- - * Copyright (c) 2014 Red Hat, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.fedoraproject.copr.client.impl; - -import static org.apache.http.HttpStatus.SC_INTERNAL_SERVER_ERROR; -import static org.apache.http.HttpStatus.SC_NOT_FOUND; -import static org.apache.http.HttpStatus.SC_OK; -import static org.apache.http.entity.ContentType.APPLICATION_JSON; -import static org.junit.Assert.fail; - -import java.io.IOException; -import java.nio.file.Path; -import java.nio.file.Paths; - -import org.apache.http.HttpException; -import org.apache.http.HttpRequest; -import org.apache.http.HttpResponse; -import org.apache.http.entity.FileEntity; -import org.apache.http.protocol.HttpContext; -import org.apache.http.protocol.HttpRequestHandler; - -/** - * @author Mikolaj Izdebski - */ -public class HttpMock - implements HttpRequestHandler -{ - private final RpcTest test; - - public HttpMock( RpcTest test ) - { - this.test = test; - } - - @Override - public void handle( HttpRequest request, HttpResponse response, HttpContext context ) - throws HttpException, IOException - { - String uri = request.getRequestLine().getUri(); - String resourceName; - - try - { - String method = request.getRequestLine().getMethod(); - if ( method.equals( "GET" ) ) - { - resourceName = test.getMock().get( uri ); - } - else if ( method.equals( "POST" ) ) - { - resourceName = test.getMock().post( uri ); - } - else - { - fail( "Unexpected method: " + method ); - throw new RuntimeException(); - } - - if ( resourceName == null ) - { - response.setStatusCode( SC_NOT_FOUND ); - } - else - { - Path resourcePath = Paths.get( "src/test/resources" ).resolve( resourceName + ".json" ); - response.setStatusCode( SC_OK ); - response.setEntity( new FileEntity( resourcePath.toFile(), APPLICATION_JSON ) ); - } - } - catch ( Exception e ) - { - response.setStatusCode( SC_INTERNAL_SERVER_ERROR ); - } - } -} diff --git a/java/copr-impl/src/test/java/org/fedoraproject/copr/client/impl/ListTest.java b/java/copr-impl/src/test/java/org/fedoraproject/copr/client/impl/ListTest.java deleted file mode 100644 index 6fb0cbb21..000000000 --- a/java/copr-impl/src/test/java/org/fedoraproject/copr/client/impl/ListTest.java +++ /dev/null @@ -1,141 +0,0 @@ -/*- - * Copyright (c) 2014 Red Hat, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.fedoraproject.copr.client.impl; - -import static org.easymock.EasyMock.expect; -import static org.easymock.EasyMock.replay; -import static org.easymock.EasyMock.verify; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.util.Iterator; -import java.util.List; - -import org.easymock.EasyMockRunner; -import org.fedoraproject.copr.client.CoprException; -import org.fedoraproject.copr.client.ListRequest; -import org.fedoraproject.copr.client.ListResult; -import org.fedoraproject.copr.client.ProjectId; -import org.junit.Test; -import org.junit.runner.RunWith; - -@RunWith( EasyMockRunner.class ) -public class ListTest - extends RpcTest -{ - @Test - public void testApiFailure() - throws Exception - { - expect( mock.get( "/api/coprs/jdaniels/" ) ).andReturn( "fail" ); - replay( mock ); - - ListRequest request = new ListRequest( "jdaniels" ); - - try - { - session.list( request ); - fail(); - } - catch ( CoprException e ) - { - verify( mock ); - assertEquals( 1, server.getAcceptedConnectionCount() ); - } - } - - @Test - public void test404() - throws Exception - { - expect( mock.get( "/api/coprs/jdaniels/" ) ).andReturn( null ); - replay( mock ); - - ListRequest request = new ListRequest( "jdaniels" ); - - try - { - session.list( request ); - fail(); - } - catch ( CoprException e ) - { - verify( mock ); - assertEquals( 1, server.getAcceptedConnectionCount() ); - - assertTrue( e.getMessage().contains( "404 Not Found" ) ); - } - } - - @Test - public void testSingleRepo() - throws Exception - { - expect( mock.get( "/api/coprs/jdaniels/" ) ).andReturn( "list1" ); - replay( mock ); - - ListRequest request = new ListRequest( "jdaniels" ); - ListResult result = session.list( request ); - - verify( mock ); - assertEquals( 1, server.getAcceptedConnectionCount() ); - - assertNotNull( result ); - List projects = result.getProjects(); - - assertNotNull( projects ); - assertEquals( 1, projects.size() ); - - ProjectId project = projects.iterator().next(); - assertEquals( "jdaniels", project.getUserName() ); - assertEquals( "log4j", project.getProjectName() ); - } - - @Test - public void testMultipleRepos() - throws Exception - { - expect( mock.get( "/api/coprs/johndoe/" ) ).andReturn( "list2" ); - replay( mock ); - - ListRequest request = new ListRequest( "johndoe" ); - ListResult result = session.list( request ); - - verify( mock ); - assertEquals( 1, server.getAcceptedConnectionCount() ); - - assertNotNull( result ); - List projects = result.getProjects(); - - assertNotNull( projects ); - assertEquals( 3, projects.size() ); - Iterator projectIterator = projects.iterator(); - - ProjectId project1 = projectIterator.next(); - assertEquals( "johndoe", project1.getUserName() ); - assertEquals( "log4j", project1.getProjectName() ); - - ProjectId project2 = projectIterator.next(); - assertEquals( "johndoe", project2.getUserName() ); - assertEquals( "xyzzy", project2.getProjectName() ); - - ProjectId project3 = projectIterator.next(); - assertEquals( "johndoe", project3.getUserName() ); - assertEquals( "my-fancy-repo", project3.getProjectName() ); - } -} diff --git a/java/copr-impl/src/test/java/org/fedoraproject/copr/client/impl/PlaygroundListTest.java b/java/copr-impl/src/test/java/org/fedoraproject/copr/client/impl/PlaygroundListTest.java deleted file mode 100644 index 55923c77f..000000000 --- a/java/copr-impl/src/test/java/org/fedoraproject/copr/client/impl/PlaygroundListTest.java +++ /dev/null @@ -1,93 +0,0 @@ -/*- - * Copyright (c) 2014 Red Hat, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.fedoraproject.copr.client.impl; - -import static org.easymock.EasyMock.expect; -import static org.easymock.EasyMock.replay; -import static org.easymock.EasyMock.verify; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.fail; - -import java.util.Iterator; -import java.util.List; - -import org.easymock.EasyMockRunner; -import org.fedoraproject.copr.client.CoprException; -import org.fedoraproject.copr.client.PlaygroundListRequest; -import org.fedoraproject.copr.client.PlaygroundListResult; -import org.fedoraproject.copr.client.ProjectId; -import org.junit.Test; -import org.junit.runner.RunWith; - -@RunWith( EasyMockRunner.class ) -public class PlaygroundListTest - extends RpcTest -{ - @Test - public void testApiFailure() - throws Exception - { - expect( mock.get( "/api/playground/list/" ) ).andReturn( "fail" ); - replay( mock ); - - PlaygroundListRequest request = new PlaygroundListRequest(); - - try - { - session.playgroundList( request ); - fail(); - } - catch ( CoprException e ) - { - verify( mock ); - assertEquals( 1, server.getAcceptedConnectionCount() ); - } - } - - @Test - public void testPlaygroundList() - throws Exception - { - expect( mock.get( "/api/playground/list/" ) ).andReturn( "playground" ); - replay( mock ); - - PlaygroundListRequest request = new PlaygroundListRequest(); - PlaygroundListResult result = session.playgroundList( request ); - - verify( mock ); - assertEquals( 1, server.getAcceptedConnectionCount() ); - - assertNotNull( result ); - List projects = result.getProjects(); - - assertNotNull( projects ); - assertEquals( 3, projects.size() ); - Iterator projectIterator = projects.iterator(); - - ProjectId project1 = projectIterator.next(); - assertEquals( "sochotni", project1.getUserName() ); - assertEquals( "fedwatch", project1.getProjectName() ); - - ProjectId project2 = projectIterator.next(); - assertEquals( "bkabrda", project2.getUserName() ); - assertEquals( "python-3.4", project2.getProjectName() ); - - ProjectId project3 = projectIterator.next(); - assertEquals( "james", project3.getUserName() ); - assertEquals( "yum-rawhide", project3.getProjectName() ); - } -} diff --git a/java/copr-impl/src/test/java/org/fedoraproject/copr/client/impl/RpcMock.java b/java/copr-impl/src/test/java/org/fedoraproject/copr/client/impl/RpcMock.java deleted file mode 100644 index a1321e414..000000000 --- a/java/copr-impl/src/test/java/org/fedoraproject/copr/client/impl/RpcMock.java +++ /dev/null @@ -1,26 +0,0 @@ -/*- - * Copyright (c) 2014 Red Hat, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.fedoraproject.copr.client.impl; - -/** - * @author Mikolaj Izdebski - */ -public interface RpcMock -{ - String get( String uri ); - - String post( String uri, String... args ); -} diff --git a/java/copr-impl/src/test/java/org/fedoraproject/copr/client/impl/RpcTest.java b/java/copr-impl/src/test/java/org/fedoraproject/copr/client/impl/RpcTest.java deleted file mode 100644 index ebbfcd27d..000000000 --- a/java/copr-impl/src/test/java/org/fedoraproject/copr/client/impl/RpcTest.java +++ /dev/null @@ -1,78 +0,0 @@ -/*- - * Copyright (c) 2014 Red Hat, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.fedoraproject.copr.client.impl; - -import java.net.InetSocketAddress; - -import org.apache.http.localserver.LocalTestServer; -import org.easymock.Mock; -import org.easymock.MockType; -import org.fedoraproject.copr.client.CoprConfiguration; -import org.fedoraproject.copr.client.CoprService; -import org.fedoraproject.copr.client.CoprSession; -import org.junit.After; -import org.junit.Before; - -/** - * @author Mikolaj Izdebski - */ -public abstract class RpcTest -{ - protected LocalTestServer server; - - protected String url; - - protected CoprSession session; - - @Mock( type = MockType.STRICT ) - protected RpcMock mock; - - public RpcMock getMock() - { - return mock; - } - - protected CoprConfiguration getConfiguration() - { - return new CoprConfiguration(); - } - - @Before - public void setUp() - throws Exception - { - server = new LocalTestServer( null, null ); - server.register( "/api/*", new HttpMock( this ) ); - server.start(); - - InetSocketAddress address = server.getServiceAddress(); - url = "http://" + address.getHostName() + ":" + address.getPort(); - - CoprConfiguration configuration = getConfiguration(); - configuration.setUrl( url ); - - CoprService copr = new DefaultCoprService(); - - session = copr.newSession( configuration ); - } - - @After - public void tearDown() - throws Exception - { - server.stop(); - } -} diff --git a/java/copr-impl/src/test/resources/build1.json b/java/copr-impl/src/test/resources/build1.json deleted file mode 100644 index 9657de8b3..000000000 --- a/java/copr-impl/src/test/resources/build1.json +++ /dev/null @@ -1,5 +0,0 @@ - { - "output": "ok", - "message": "Build was added to log4j.", - "id": 5 - } diff --git a/java/copr-impl/src/test/resources/detail1.json b/java/copr-impl/src/test/resources/detail1.json deleted file mode 100644 index 1e8f3a516..000000000 --- a/java/copr-impl/src/test/resources/detail1.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "detail": { - "additional_repos": "", - "description": "Fixed or tweaked versions of some Fedora packages, for personal use.", - "instructions": "Nothing complicated, really...", - "last_modified": 1407916203, - "name": "override", - "yum_repos": { - "fedora-20-x86_64": "http://copr-be.cloud.fedoraproject.org/results/mizdebsk/override/fedora-20-x86_64/", - "fedora-21-x86_64": "http://copr-be.cloud.fedoraproject.org/results/mizdebsk/override/fedora-21-x86_64/", - "fedora-rawhide-x86_64": "http://copr-be.cloud.fedoraproject.org/results/mizdebsk/override/fedora-rawhide-x86_64/" - } - }, - "output": "ok" -} diff --git a/java/copr-impl/src/test/resources/fail.json b/java/copr-impl/src/test/resources/fail.json deleted file mode 100644 index 5ea7f3ba2..000000000 --- a/java/copr-impl/src/test/resources/fail.json +++ /dev/null @@ -1 +0,0 @@ -{"output":"notok"} diff --git a/java/copr-impl/src/test/resources/list1.json b/java/copr-impl/src/test/resources/list1.json deleted file mode 100644 index d211bc339..000000000 --- a/java/copr-impl/src/test/resources/list1.json +++ /dev/null @@ -1,15 +0,0 @@ - { - "output": "ok", - "repos": [ - { - "yum_repos": { - "fedora-19-i686": "https://copr-be.cloud.fedoraproject.org/results/jdaniels/log4j/fedora-19-i686/", - "fedora-19-x86_64": "https://copr-be.cloud.fedoraproject.org/results/jdaniels/log4j/fedora-19-x86_64/" - }, - "additional_repos": "", - "instructions": "", - "name": "log4j", - "description": "Java logging package" - } - ] - } diff --git a/java/copr-impl/src/test/resources/list2.json b/java/copr-impl/src/test/resources/list2.json deleted file mode 100644 index aae875dba..000000000 --- a/java/copr-impl/src/test/resources/list2.json +++ /dev/null @@ -1,33 +0,0 @@ - { - "output": "ok", - "repos": [ - { - "yum_repos": { - "fedora-19-i686": "https://copr-be.cloud.fedoraproject.org/results/jdaniels/log4j/fedora-19-i686/", - "fedora-19-x86_64": "https://copr-be.cloud.fedoraproject.org/results/jdaniels/log4j/fedora-19-x86_64/" - }, - "additional_repos": "", - "instructions": "", - "name": "log4j", - "description": "Java logging package" - }, { - "yum_repos": { - "fedora-19-i686": "https://copr-be.cloud.fedoraproject.org/results/jdaniels/log4j/fedora-19-i686/", - "fedora-19-x86_64": "https://copr-be.cloud.fedoraproject.org/results/jdaniels/log4j/fedora-19-x86_64/" - }, - "additional_repos": "", - "instructions": "", - "name": "xyzzy", - "description": "Java logging package" - }, { - "yum_repos": { - "fedora-19-i686": "https://copr-be.cloud.fedoraproject.org/results/jdaniels/log4j/fedora-19-i686/", - "fedora-19-x86_64": "https://copr-be.cloud.fedoraproject.org/results/jdaniels/log4j/fedora-19-x86_64/" - }, - "additional_repos": "", - "instructions": "", - "name": "my-fancy-repo", - "description": "Java logging package" - } - ] - } diff --git a/java/copr-impl/src/test/resources/playground.json b/java/copr-impl/src/test/resources/playground.json deleted file mode 100644 index cc94d43e3..000000000 --- a/java/copr-impl/src/test/resources/playground.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "output": "ok", - "repos": [ - { - "chroots": [ - "epel-6-i386", - "epel-6-x86_64", - "fedora-rawhide-x86_64", - "fedora-rawhide-i386", - "fedora-20-x86_64", - "fedora-20-i386", - "epel-7-x86_64" - ], - "coprname": "fedwatch", - "username": "sochotni" - }, - { - "chroots": [ - "fedora-rawhide-x86_64", - "fedora-rawhide-i386" - ], - "coprname": "python-3.4", - "username": "bkabrda" - }, - { - "chroots": [ - "fedora-19-i386", - "epel-6-i386", - "fedora-20-i386", - "fedora-rawhide-i386", - "fedora-19-x86_64", - "epel-6-x86_64", - "fedora-rawhide-x86_64", - "fedora-20-x86_64", - "epel-7-x86_64" - ], - "coprname": "yum-rawhide", - "username": "james" - } - ] -} diff --git a/java/copr-java.spec b/java/copr-java.spec deleted file mode 100644 index e99fe5169..000000000 --- a/java/copr-java.spec +++ /dev/null @@ -1,47 +0,0 @@ -Name: copr-java -Version: 0.2 -Release: 1%{?dist} -Summary: COPR Java client -License: Apache-2.0 -URL: https://github.com/fedora-copr/copr - -# Source is created by -# git clone https://github.com/fedora-copr/copr.git -# cd copr/java -# tito build --tgz -Source0: %{name}-%{version}.tar.gz - -BuildRequires: maven-local - -%description -COPR is lightweight build system. It allows you to create new project in WebUI, -and submit new builds and COPR will create yum repository from latest builds. - -This package contains Java client library. - -%package javadoc -Summary: API documentation for %{name} - -%description javadoc -This package provides %{summary}. - -%prep -%setup -q - -%build -%mvn_build - -%install -%mvn_install - -%files -f .mfiles -%license LICENSE -%doc NOTICE - -%files javadoc -f .mfiles-javadoc -%license LICENSE -%doc NOTICE - -%changelog -* Tue Sep 16 2014 Mikolaj Izdebski -- Initial packaging diff --git a/java/pom.xml b/java/pom.xml deleted file mode 100644 index 078814937..000000000 --- a/java/pom.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - 4.0.0 - org.fedoraproject.copr.client - copr-parent - 0.0.0-SNAPSHOT - pom - Copr Client Parent POM - - copr-api - copr-impl - copr-cli - - - - - maven-compiler-plugin - - 1.7 - 1.7 - - - - - - Red Hat, Inc. - http://www.redhat.com/ - - - Bugzilla - https://bugzilla.redhat.com/ - -