use of org.apache.wicket.RestartResponseException in project midpoint by Evolveum.
the class PageResourceEdit method loadResource.
private ObjectViewDto loadResource() {
if (!isEditing()) {
return new ObjectViewDto();
}
ObjectViewDto dto;
try {
PrismObject<ResourceType> resource = loadResource(null);
String xml = getPrismContext().serializeObjectToString(resource, PrismContext.LANG_XML);
dto = new ObjectViewDto(resource.getOid(), WebComponentUtil.getName(resource), resource, xml);
} catch (Exception ex) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load resource", ex);
throw new RestartResponseException(PageResources.class);
}
return dto;
}
use of org.apache.wicket.RestartResponseException in project midpoint by Evolveum.
the class DynamicFormPanel method initialize.
private void initialize(final PrismObject<O> prismObject, String formOid, Form<?> mainForm, final Task task, final PageBase parentPage) {
if (prismObject == null) {
getSession().error(getString("DynamicFormPanel.object.must.not.be.null"));
throw new RestartResponseException(parentPage);
}
// setParent(parentPage);
form = loadForm(formOid, task, parentPage);
if (form == null || form.getFormDefinition() == null) {
LOGGER.debug("No form or form definition; form OID = {}", formOid);
// to avoid wicket exceptions
add(new Label(ID_FORM_FIELDS));
return;
}
final ObjectWrapperFactory owf = new ObjectWrapperFactory(parentPage);
ObjectWrapper<O> objectWrapper = createObjectWrapper(owf, task, prismObject);
wrapperModel = new LoadableModel<ObjectWrapper<O>>() {
private static final long serialVersionUID = 1L;
@Override
protected ObjectWrapper<O> load() {
return objectWrapper;
}
};
initLayout(mainForm, parentPage);
}
use of org.apache.wicket.RestartResponseException in project midpoint by Evolveum.
the class PageAccounts method loadResources.
private List<ResourceItemDto> loadResources() {
List<ResourceItemDto> resources = new ArrayList<>();
OperationResult result = new OperationResult(OPERATION_LOAD_RESOURCES);
try {
List<PrismObject<ResourceType>> objects = getModelService().searchObjects(ResourceType.class, null, SelectorOptions.createCollection(GetOperationOptions.createNoFetch()), createSimpleTask(OPERATION_LOAD_RESOURCES), result);
if (objects != null) {
for (PrismObject<ResourceType> object : objects) {
StringBuilder nameBuilder = new StringBuilder(WebComponentUtil.getName(object));
PrismProperty<OperationResultType> fetchResult = object.findProperty(ResourceType.F_FETCH_RESULT);
if (fetchResult != null) {
nameBuilder.append(" (");
nameBuilder.append(fetchResult.getRealValue().getStatus());
nameBuilder.append(")");
}
resources.add(new ResourceItemDto(object.getOid(), nameBuilder.toString()));
}
}
result.recordSuccess();
} catch (Exception ex) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load resources", ex);
result.recordFatalError("Couldn't load resources, reason: " + ex.getMessage(), ex);
} finally {
if (result.isUnknown()) {
result.computeStatus();
}
}
Collections.sort(resources);
if (!WebComponentUtil.isSuccessOrHandledError(result)) {
showResult(result, false);
throw new RestartResponseException(PageDashboard.class);
}
return resources;
}
use of org.apache.wicket.RestartResponseException in project midpoint by Evolveum.
the class PageAccounts method createFilesModel.
private LoadableModel<List<String>> createFilesModel() {
return new LoadableModel<List<String>>(false) {
@Override
protected List<String> load() {
String[] filesArray;
try {
MidpointConfiguration config = getMidpointConfiguration();
File exportFolder = new File(config.getMidpointHome() + "/export");
filesArray = exportFolder.list(new FilenameFilter() {
@Override
public boolean accept(java.io.File dir, String name) {
return name.endsWith("xml");
}
});
} catch (Exception ex) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't list files", ex);
getSession().error("Couldn't list files, reason: " + ex.getMessage());
throw new RestartResponseException(PageDashboard.class);
}
if (filesArray == null) {
return new ArrayList<>();
}
List<String> list = Arrays.asList(filesArray);
Collections.sort(list);
return list;
}
};
}
use of org.apache.wicket.RestartResponseException in project midpoint by Evolveum.
the class PageDebugView method initObjectViewObject.
private LoadableModel<ObjectViewDto<?>> initObjectViewObject() {
return new LoadableModel<ObjectViewDto<?>>(false) {
private static final long serialVersionUID = 1L;
@Override
protected ObjectViewDto<?> load() {
ObjectViewDto<?> objectViewDto = new ObjectViewDto<>();
StringValue objectOid = getPageParameters().get(PARAM_OBJECT_ID);
if (objectOid == null || StringUtils.isEmpty(objectOid.toString())) {
getSession().error(getString("pageDebugView.message.oidNotDefined"));
throw new RestartResponseException(PageDebugList.class);
}
Task task = createSimpleTask(OPERATION_LOAD_OBJECT);
// todo is this result != null ?
OperationResult result = task.getResult();
try {
MidPointApplication application = PageDebugView.this.getMidpointApplication();
Class<? extends ObjectType> type = getTypeFromParameters();
GetOperationOptionsBuilder optionsBuilder = getSchemaService().getOperationOptionsBuilder().raw().resolveNames().tolerateRawData();
if (getPageParameters().get(PARAM_SHOW_ALL_ITEMS).toBoolean(true)) {
optionsBuilder = optionsBuilder.retrieve();
}
PrismObject<? extends ObjectType> object = getModelService().getObject(type, objectOid.toString(), optionsBuilder.build(), task, result);
PrismContext context = application.getPrismContext();
String lex = context.serializerFor(dataLanguage).serialize(object);
objectViewDto = new ObjectViewDto<>(object.getOid(), WebComponentUtil.getName(object), object, lex);
result.recomputeStatus();
} catch (Exception ex) {
result.recordFatalError(getString("WebModelUtils.couldntLoadObject"), ex);
}
showResult(result, false);
if (!WebComponentUtil.isSuccessOrHandledErrorOrWarning(result)) {
showResult(result, false);
throw new RestartResponseException(PageDebugList.class);
}
return objectViewDto;
}
};
}
Aggregations