-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #299 from ehrbase/fature/298_clean_up_tests
added admin point to delete templates
- Loading branch information
Showing
6 changed files
with
85 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
client/src/main/java/org/ehrbase/client/openehrclient/AdminTemplateEndpoint.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package org.ehrbase.client.openehrclient; | ||
|
||
public interface AdminTemplateEndpoint { | ||
int delete(String templateId); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
.../org/ehrbase/client/openehrclient/defaultrestclient/DefaultRestAdminTemplateEndpoint.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Copyright (c) 2020 Christian Chevalley (Hannover Medical School) and Vitasystems GmbH | ||
* | ||
* This file is part of project EHRbase | ||
* | ||
* 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.ehrbase.client.openehrclient.defaultrestclient; | ||
|
||
import org.apache.http.HttpResponse; | ||
import org.ehrbase.client.openehrclient.AdminTemplateEndpoint; | ||
|
||
import java.net.URI; | ||
|
||
/** | ||
* Requires that the Admin endpoint is active. | ||
* | ||
* Parameters in .yml configuration matching the runtime context as: | ||
* | ||
* admin-api: | ||
* active: true | ||
* allowDeleteAll: true | ||
*/ | ||
public class DefaultRestAdminTemplateEndpoint implements AdminTemplateEndpoint { | ||
|
||
public static final String ADMIN_TEMPLATE_PATH = "rest/admin/template/"; | ||
|
||
private final DefaultRestClient defaultRestClient; | ||
|
||
public DefaultRestAdminTemplateEndpoint(DefaultRestClient defaultRestClient) { | ||
this.defaultRestClient = defaultRestClient; | ||
} | ||
|
||
|
||
@Override | ||
public int delete(String templateId) { | ||
if (templateId == null) | ||
return 0; | ||
|
||
URI uri = defaultRestClient.getConfig().getBaseUri().resolve(ADMIN_TEMPLATE_PATH + templateId); | ||
|
||
HttpResponse response = | ||
defaultRestClient.internalDelete( | ||
uri, | ||
null); | ||
|
||
return response.getStatusLine().getStatusCode(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters