use of org.apache.wicket.RestartResponseException in project midpoint by Evolveum.
the class ObjectNameColumn method populateItem.
@Override
public void populateItem(final Item<ICellPopulator<SelectableBean<O>>> cellItem, String componentId, final IModel<SelectableBean<O>> rowModel) {
IModel<String> labelModel = new AbstractReadOnlyModel<String>() {
private static final long serialVersionUID = 1L;
@Override
public String getObject() {
SelectableBean<O> selectableBean = rowModel.getObject();
O value = selectableBean.getValue();
if (value == null) {
OperationResult result = selectableBean.getResult();
OperationResultStatusPresentationProperties props = OperationResultStatusPresentationProperties.parseOperationalResultStatus(result.getStatus());
return cellItem.getString(props.getStatusLabelKey());
} else {
String name = WebComponentUtil.getName(value);
if (selectableBean.getResult() != null) {
StringBuilder complexName = new StringBuilder();
complexName.append(name);
complexName.append(" (");
complexName.append(selectableBean.getResult().getStatus());
complexName.append(")");
return complexName.toString();
}
return name;
}
}
};
if (isClickable(rowModel)) {
// beware: rowModel is very probably resolved at this moment; but it seems to cause no problems
cellItem.add(new LinkPanel(componentId, labelModel) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
SelectableBean<O> selectableBean = rowModel.getObject();
O value = selectableBean.getValue();
if (value == null) {
OperationResult result = selectableBean.getResult();
throw new RestartResponseException(new PageOperationResult(result));
} else {
if (selectableBean.getResult() != null) {
throw new RestartResponseException(new PageOperationResult(selectableBean.getResult()));
} else {
ObjectNameColumn.this.onClick(target, rowModel);
}
}
}
});
} else {
cellItem.add(new Label(componentId, labelModel));
}
}
use of org.apache.wicket.RestartResponseException in project midpoint by Evolveum.
the class PageReport method loadReport.
private ReportDto loadReport() {
StringValue reportOid = getPageParameters().get(OnePageParameterEncoder.PARAMETER);
Task task = createSimpleTask(OPERATION_LOAD_REPORT);
OperationResult result = task.getResult();
PrismObject<ReportType> prismReport = WebModelServiceUtils.loadObject(ReportType.class, reportOid.toString(), this, task, result);
if (prismReport == null) {
LOGGER.error("Couldn't load report.");
throw new RestartResponseException(PageReports.class);
}
return new ReportDto(prismReport.asObjectable());
// return prismReport;
}
use of org.apache.wicket.RestartResponseException in project midpoint by Evolveum.
the class PageReport method createFullXmlModel.
private IModel<String> createFullXmlModel() {
return new IModel<String>() {
@Override
public String getObject() {
PrismObject report = model.getObject().getObject();
if (report == null) {
return null;
}
try {
return getPrismContext().serializeObjectToString(report, PrismContext.LANG_XML);
} catch (SchemaException ex) {
getSession().error(getString("PageReport.message.cantSerializeFromObjectToString") + ex);
throw new RestartResponseException(PageError.class);
}
}
@Override
public void setObject(String object) {
OperationResult result = new OperationResult(OPERATION_VALIDATE_REPORT);
Holder<PrismObject<ReportType>> reportHolder = new Holder<>(null);
try {
validateObject(object, reportHolder, PrismContext.LANG_XML, true, result);
model.getObject().setObject(reportHolder.getValue());
} catch (Exception e) {
LOGGER.error("Could not set object. Validation problem occured." + result.getMessage());
result.recordFatalError("Could not set object. Validation problem occured,", e);
showResult(result, "Could not set object. Validation problem occured.");
}
}
@Override
public void detach() {
}
};
}
use of org.apache.wicket.RestartResponseException in project midpoint by Evolveum.
the class PageMyPasswordQuestions method loadUserWrapper.
private ObjectWrapper loadUserWrapper(PrismObject<UserType> userToEdit) {
OperationResult result = new OperationResult(OPERATION_LOAD_USER);
PrismObject<UserType> user = null;
Task task = createSimpleTask(OPERATION_LOAD_USER);
try {
Collection options = SelectorOptions.createCollection(UserType.F_CREDENTIALS, GetOperationOptions.createRetrieve(RetrieveOption.INCLUDE));
user = getModelService().getObject(UserType.class, SecurityUtils.getPrincipalUser().getOid(), options, task, result);
result.recordSuccess();
} catch (Exception ex) {
result.recordFatalError("Couldn't get user.", ex);
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load user PageMyQuestions", ex);
}
showResult(result, false);
if (user == null) {
throw new RestartResponseException(PageDashboard.class);
}
ContainerStatus status = ContainerStatus.MODIFYING;
ObjectWrapperFactory owf = new ObjectWrapperFactory(this);
ObjectWrapper wrapper;
try {
wrapper = owf.createObjectWrapper("pageMyPasswordQuestions.userDetails", null, user, status, task);
} catch (Exception ex) {
result.recordFatalError("Couldn't get user.", ex);
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load user", ex);
wrapper = owf.createObjectWrapper("pageMyPasswordQuestions.userDetails", null, user, null, null, status, false);
}
// ObjectWrapper wrapper = new ObjectWrapper("pageUser.userDetails", null, user, status);
showResult(wrapper.getResult(), false);
return wrapper;
}
use of org.apache.wicket.RestartResponseException in project midpoint by Evolveum.
the class WebModelServiceUtils method createSimpleTask.
public static Task createSimpleTask(String operation, PrismObject<UserType> owner, TaskManager manager) {
Task task = manager.createTaskInstance(operation);
if (owner == null) {
MidPointPrincipal user = SecurityUtils.getPrincipalUser();
if (user == null) {
throw new RestartResponseException(PageLogin.class);
} else {
owner = user.getUser().asPrismObject();
}
}
task.setOwner(owner);
task.setChannel(SchemaConstants.CHANNEL_GUI_USER_URI);
return task;
}
Aggregations