use of org.apache.wicket.RestartResponseException in project midpoint by Evolveum.
the class PageAdminObjectDetails method loadObjectWrapper.
protected ObjectWrapper<O> loadObjectWrapper(PrismObject<O> objectToEdit) {
Task task = createSimpleTask(OPERATION_LOAD_OBJECT);
OperationResult result = task.getResult();
PrismObject<O> object = null;
Collection<SelectorOptions<GetOperationOptions>> loadOptions = null;
try {
if (!isEditingFocus()) {
if (objectToEdit == null) {
LOGGER.trace("Loading object: New object (creating)");
O focusType = createNewObject();
getMidpointApplication().getPrismContext().adopt(focusType);
object = (PrismObject<O>) focusType.asPrismObject();
} else {
LOGGER.trace("Loading object: New object (supplied): {}", objectToEdit);
object = objectToEdit;
}
} else {
loadOptions = SelectorOptions.createCollection(UserType.F_JPEG_PHOTO, GetOperationOptions.createRetrieve(RetrieveOption.INCLUDE));
String focusOid = getObjectOidParameter();
object = WebModelServiceUtils.loadObject(getCompileTimeClass(), focusOid, loadOptions, this, task, result);
LOGGER.trace("Loading object: Existing object (loadled): {} -> {}", focusOid, object);
}
result.recordSuccess();
} catch (Exception ex) {
result.recordFatalError("Couldn't get object.", ex);
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load object", ex);
}
showResult(result, false);
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Loaded object:\n{}", object.debugDump());
}
if (object == null) {
if (isEditingFocus()) {
getSession().error(getString("pageAdminFocus.message.cantEditFocus"));
} else {
getSession().error(getString("pageAdminFocus.message.cantNewFocus"));
}
throw new RestartResponseException(getRestartResponsePage());
}
ContainerStatus status = isEditingFocus() ? ContainerStatus.MODIFYING : ContainerStatus.ADDING;
ObjectWrapper<O> wrapper;
ObjectWrapperFactory owf = new ObjectWrapperFactory(this);
try {
wrapper = owf.createObjectWrapper("pageAdminFocus.focusDetails", null, object, status, task);
} catch (Exception ex) {
result.recordFatalError("Couldn't get user.", ex);
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load user", ex);
wrapper = owf.createObjectWrapper("pageAdminFocus.focusDetails", null, object, null, null, status, false);
}
wrapper.setLoadOptions(loadOptions);
showResult(wrapper.getResult(), false);
loadParentOrgs(wrapper, task, result);
wrapper.setShowEmpty(!isEditingFocus());
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Loaded focus wrapper:\n{}", wrapper.debugDump());
}
return wrapper;
}
use of org.apache.wicket.RestartResponseException in project midpoint by Evolveum.
the class PrismPropertyRealValueFromContainerableModel method getObject.
@Override
public T getObject() {
C object = model.getObject();
PrismProperty<T> property;
try {
property = object.asPrismContainerValue().findOrCreateProperty(path);
} catch (SchemaException ex) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't create property in path {}", ex, path);
//todo show message in page error [lazyman]
throw new RestartResponseException(PageError.class);
}
return getRealValue(property != null ? property.getRealValue() : null);
}
use of org.apache.wicket.RestartResponseException in project midpoint by Evolveum.
the class PrismPropertyRealValueFromObjectWrapperModel method getObject.
@Override
public T getObject() {
PrismProperty<T> property;
try {
property = getPrismObject().findOrCreateProperty(path);
} catch (SchemaException ex) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't create property in path {}", ex, path);
//todo show message in page error [lazyman]
throw new RestartResponseException(PageError.class);
}
T val = getRealValue(property != null ? property.getRealValue() : null);
if (val == null) {
return defaultValue;
} else {
return val;
}
}
use of org.apache.wicket.RestartResponseException in project midpoint by Evolveum.
the class OrgTreeProvider method getChildren.
@Override
public Iterator<? extends SelectableBean<OrgType>> getChildren(SelectableBean<OrgType> node) {
// getAvailableData().clear();
LOGGER.debug("Loading children for {}", new Object[] { node });
Iterator<SelectableBean<OrgType>> iterator = null;
ObjectQuery query = QueryBuilder.queryFor(ObjectType.class, getPageBase().getPrismContext()).isDirectChildOf(// TODO what if getValue==null
node.getValue().getOid()).asc(ObjectType.F_NAME).build();
OperationResult result = new OperationResult(LOAD_ORG_UNITS);
try {
// Collection<SelectorOptions<GetOperationOptions>> options = WebModelServiceUtils.createOptionsForParentOrgRefs();
Collection<SelectorOptions<GetOperationOptions>> options = null;
Task task = getPageBase().createSimpleTask(LOAD_ORG_UNITS);
List<PrismObject<OrgType>> units = getModelService().searchObjects(OrgType.class, query, options, task, result);
LOGGER.debug("Found {} units.", units.size());
List<SelectableBean<OrgType>> list = new ArrayList<SelectableBean<OrgType>>();
for (PrismObject<OrgType> unit : units) {
SelectableBean<OrgType> selectable = createObjectWrapper(node, unit);
list.add(selectable);
// if (getAvailableData().contains(selectable)){
// getAvailableData().remove(selectable);
// }
// getAvailableData().add(selectable);
}
getAvailableData().addAll(list);
// Collections.sort(list);
iterator = list.iterator();
} catch (Exception ex) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load children", ex);
result.recordFatalError("Unable to load org unit", ex);
} finally {
result.computeStatus();
}
if (WebComponentUtil.showResultInPage(result)) {
getPageBase().showResult(result);
throw new RestartResponseException(PageOrgTree.class);
}
if (iterator == null) {
iterator = new ArrayList<SelectableBean<OrgType>>().iterator();
}
LOGGER.debug("Finished loading children.");
return iterator;
}
use of org.apache.wicket.RestartResponseException in project midpoint by Evolveum.
the class PageAdminResources method loadResource.
protected PrismObject<ResourceType> loadResource(Collection<SelectorOptions<GetOperationOptions>> options) {
OperationResult result = new OperationResult(OPERATION_LOAD_RESOURCE);
PrismObject<ResourceType> resource = null;
try {
Task task = createSimpleTask(OPERATION_LOAD_RESOURCE);
LOGGER.trace("getObject(resource) oid={}, options={}", getResourceOid(), options);
resource = getModelService().getObject(ResourceType.class, getResourceOid(), options, task, result);
result.recomputeStatus();
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("getObject(resource) result\n:{}", result.debugDump());
}
} catch (Exception ex) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't get resource", ex);
result.recordFatalError("Couldn't get resource, reason: " + ex.getMessage(), ex);
}
if (!WebComponentUtil.isSuccessOrHandledError(result)) {
if (resource != null) {
showResult(result);
} else {
getSession().error(getString("pageAdminResources.message.cantLoadResource"));
throw new RestartResponseException(PageResources.class);
}
}
return resource;
}
Aggregations