use of org.entando.entando.aps.system.services.widgettype.WidgetType in project entando-core by entando.
the class ApiWidgetTypeInterface method updateWidgetType.
public StringApiResponse updateWidgetType(JAXBWidgetType jaxbWidgetType) throws ApiException, Throwable {
StringApiResponse response = new StringApiResponse();
WidgetType widgetTypeToUpdate = null;
List<GuiFragment> addedFragments = new ArrayList<GuiFragment>();
List<GuiFragment> updatedFragments = new ArrayList<GuiFragment>();
try {
widgetTypeToUpdate = this.getWidgetTypeManager().getWidgetType(jaxbWidgetType.getCode());
if (null == widgetTypeToUpdate) {
throw new ApiException(IApiErrorCodes.API_VALIDATION_ERROR, "WidgetType with code " + jaxbWidgetType.getCode() + " does not exists", Response.Status.CONFLICT);
}
WidgetType widgetType = jaxbWidgetType.getModifiedWidgetType(this.getWidgetTypeManager());
this.checkAndSaveFragment(widgetType, jaxbWidgetType, false, response, addedFragments, updatedFragments);
this.getWidgetTypeManager().updateWidgetType(widgetType.getCode(), widgetType.getTitles(), widgetType.getConfig(), widgetType.getMainGroup());
response.setResult(IResponseBuilder.SUCCESS, null);
} catch (ApiException ae) {
this.revertPreviousObject(widgetTypeToUpdate, addedFragments, updatedFragments);
throw ae;
} catch (Throwable t) {
this.revertPreviousObject(widgetTypeToUpdate, addedFragments, updatedFragments);
_logger.error("Error updating widget type", t);
throw t;
}
return response;
}
use of org.entando.entando.aps.system.services.widgettype.WidgetType in project entando-core by entando.
the class ApiWidgetTypeInterface method getWidgetTypes.
public List<LinkedListItem> getWidgetTypes(Properties properties) throws Throwable {
List<LinkedListItem> list = new ArrayList<LinkedListItem>();
try {
List<WidgetType> types = this.getWidgetTypeManager().getWidgetTypes();
for (int i = 0; i < types.size(); i++) {
WidgetType widgetType = types.get(i);
String url = this.getApiResourceUrl(widgetType, properties.getProperty(SystemConstants.API_APPLICATION_BASE_URL_PARAMETER), properties.getProperty(SystemConstants.API_LANG_CODE_PARAMETER), (MediaType) properties.get(SystemConstants.API_PRODUCES_MEDIA_TYPE_PARAMETER));
LinkedListItem item = new LinkedListItem();
item.setCode(widgetType.getCode());
item.setUrl(url);
list.add(item);
}
} catch (Throwable t) {
_logger.error("Error extracting list of widget types", t);
throw t;
}
return list;
}
use of org.entando.entando.aps.system.services.widgettype.WidgetType in project entando-core by entando.
the class ApiWidgetTypeInterface method getApiResourceUrl.
@Override
public String getApiResourceUrl(Object object, String applicationBaseUrl, String langCode, MediaType mediaType) {
if (!(object instanceof WidgetType) || null == applicationBaseUrl || null == langCode) {
return null;
}
WidgetType widgetType = (WidgetType) object;
StringBuilder stringBuilder = new StringBuilder(applicationBaseUrl);
// ?code=").append(widgetType.getCode());
stringBuilder.append("api/rs/").append(langCode).append("/core/widgetType");
if (null == mediaType || mediaType.equals(MediaType.APPLICATION_XML_TYPE)) {
stringBuilder.append(".xml");
} else {
stringBuilder.append(".json");
}
stringBuilder.append("?code=").append(widgetType.getCode());
return stringBuilder.toString();
}
use of org.entando.entando.aps.system.services.widgettype.WidgetType in project entando-core by entando.
the class ApiWidgetTypeInterface method deleteWidgetType.
public void deleteWidgetType(Properties properties) throws ApiException, Throwable {
String code = properties.getProperty("code");
try {
WidgetType widgetType = this.getWidgetTypeManager().getWidgetType(code);
if (null == widgetType) {
throw new ApiException(IApiErrorCodes.API_VALIDATION_ERROR, "Widget Type with code " + code + " does not exists", Response.Status.CONFLICT);
}
if (widgetType.isLocked()) {
throw new ApiException(IApiErrorCodes.API_VALIDATION_ERROR, "Widget Type '" + code + "' is locked", Response.Status.CONFLICT);
}
List<IPage> referencedPages = this.getPageManager().getDraftWidgetUtilizers(code);
if (null != referencedPages && !referencedPages.isEmpty()) {
throw new ApiException(IApiErrorCodes.API_VALIDATION_ERROR, "Widget Type '" + code + "' is published into some pages", Response.Status.CONFLICT);
}
this.getWidgetTypeManager().deleteWidgetType(code);
} catch (ApiException ae) {
throw ae;
} catch (Throwable t) {
_logger.error("Error deleting widget type throw api", t);
throw t;
}
}
use of org.entando.entando.aps.system.services.widgettype.WidgetType in project entando-core by entando.
the class JAXBWidgetType method getNewWidgetType.
public WidgetType getNewWidgetType(IWidgetTypeManager widgetTypeManager) {
WidgetType type = new WidgetType();
type.setCode(this.getCode());
type.setTitles(this.getTitles());
List<WidgetTypeParameter> parameters = this.getTypeParameters();
if (null != parameters && !parameters.isEmpty()) {
type.setTypeParameters(parameters);
type.setAction("configSimpleParameter");
} else {
ApsProperties configuration = this.getConfig();
String parentTypeCode = this.getParentTypeCode();
if (null != parentTypeCode && null != configuration && !configuration.isEmpty()) {
WidgetType parentType = widgetTypeManager.getWidgetType(parentTypeCode);
type.setParentType(parentType);
type.setConfig(configuration);
}
}
type.setMainGroup(this.getMainGroup());
// type.setLocked(this.isLocked());
type.setPluginCode(this.getPluginCode());
return type;
}
Aggregations