use of org.entando.entando.aps.system.services.api.model.ApiMethod in project entando-core by entando.
the class ApiCatalogManager method updateMethodConfig.
@Override
public void updateMethodConfig(ApiMethod apiMethod) throws ApsSystemException {
try {
ApiMethod masterMethod = this.checkMethod(apiMethod);
this.getApiCatalogDAO().saveApiStatus(apiMethod);
masterMethod.setStatus(apiMethod.getStatus());
masterMethod.setHidden(apiMethod.getHidden());
masterMethod.setRequiredAuth(apiMethod.getRequiredAuth());
String requiredPermission = apiMethod.getRequiredPermission();
if (null != requiredPermission && requiredPermission.trim().length() > 0) {
masterMethod.setRequiredPermission(requiredPermission);
} else {
masterMethod.setRequiredPermission(null);
}
String resourceCode = ApiResource.getCode(masterMethod.getNamespace(), masterMethod.getResourceName());
ApiResource resource = this.getResourceCacheWrapper().getMasterResource(resourceCode);
this.getResourceCacheWrapper().updateResource(resource);
} catch (Throwable t) {
logger.error("Error error updating api status : resource '{}' method '{}'", apiMethod.getResourceName(), apiMethod.getHttpMethod(), t);
throw new ApsSystemException("Error updating api status", t);
}
}
use of org.entando.entando.aps.system.services.api.model.ApiMethod in project entando-core by entando.
the class ApiCatalogManagerTest method testGetMethod.
@Test
public void testGetMethod() throws Throwable {
when(resourceCacheWrapper.getMasterResource("getService")).thenReturn(createResource(null, "getService"));
ApiMethod method = this.apiCatalogManager.getMethod(ApiMethod.HttpMethod.GET, "getService");
assertNotNull(method);
assertTrue(method.isActive());
}
use of org.entando.entando.aps.system.services.api.model.ApiMethod in project entando-core by entando.
the class ApiCatalogManagerIntegrationTest method testGetMethod.
public void testGetMethod() throws Throwable {
ApiMethod method = this.getApiCatalogManager().getMethod(ApiMethod.HttpMethod.GET, "getService");
assertNotNull(method);
assertTrue(method.isActive());
}
use of org.entando.entando.aps.system.services.api.model.ApiMethod in project entando-core by entando.
the class ApiCatalogManagerIntegrationTest method testUpdateMethodStatus.
public void testUpdateMethodStatus() throws Throwable {
ApiMethod method = this.getApiCatalogManager().getMethod(ApiMethod.HttpMethod.GET, "getService");
method.setStatus(false);
this.getApiCatalogManager().updateMethodConfig(method);
method = this.getApiCatalogManager().getMethod(ApiMethod.HttpMethod.GET, "getService");
assertFalse(method.isActive());
}
use of org.entando.entando.aps.system.services.api.model.ApiMethod in project entando-core by entando.
the class TestApiI18nLabelInterface method testCreateNewLabel.
protected void testCreateNewLabel(MediaType mediaType) throws Throwable {
String key = "TEST_LABEL_KEY";
String label = this._i18nManager.getLabel(key, "it");
assertNull(label);
ApsProperties labels = new ApsProperties();
labels.put("en", "Test label");
labels.put("it", "Label di Test");
JAXBI18nLabel jaxbLabel = new JAXBI18nLabel(key, labels);
ApiResource labelResource = this.getApiCatalogManager().getResource("core", "i18nlabel");
ApiMethod postMethod = labelResource.getPostMethod();
Properties properties = super.createApiProperties("admin", "it", mediaType);
try {
Object response = this.getResponseBuilder().createResponse(postMethod, jaxbLabel, properties);
assertNotNull(response);
assertTrue(response instanceof StringApiResponse);
assertEquals(IResponseBuilder.SUCCESS, ((StringApiResponse) response).getResult());
label = this._i18nManager.getLabel(key, "it");
assertEquals("Label di Test", label);
} catch (Exception e) {
throw e;
} finally {
this._i18nManager.deleteLabelGroup(key);
}
}
Aggregations