use of com.evolveum.midpoint.web.page.admin.users.dto.FocusSubwrapperDto in project midpoint by Evolveum.
the class PageAdminFocus method loadSubWrapperDto.
private <S extends ObjectType> FocusSubwrapperDto<S> loadSubWrapperDto(Class<S> type, String oid, boolean noFetch, Task task) {
if (oid == null) {
return null;
}
OperationResult subResult = task.getResult().createMinorSubresult(OPERATION_LOAD_SHADOW);
String resourceName = null;
try {
Collection<SelectorOptions<GetOperationOptions>> loadOptions = null;
if (ShadowType.class.equals(type)) {
GetOperationOptions resourceOption = GetOperationOptions.createResolve();
resourceOption.setReadOnly(true);
loadOptions = SelectorOptions.createCollection(ShadowType.F_RESOURCE, resourceOption);
}
if (noFetch) {
GetOperationOptions rootOptions = SelectorOptions.findRootOptions(loadOptions);
if (rootOptions == null) {
loadOptions.add(new SelectorOptions<GetOperationOptions>(GetOperationOptions.createNoFetch()));
} else {
rootOptions.setNoFetch(true);
}
}
PrismObject<S> projection = WebModelServiceUtils.loadObject(type, oid, loadOptions, this, task, subResult);
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Loaded projection {} ({}):\n{}", oid, loadOptions, projection == null ? null : projection.debugDump());
}
if (projection == null) {
// No access or error
return null;
}
S projectionType = projection.asObjectable();
OperationResultType fetchResult = projectionType.getFetchResult();
StringBuilder description = new StringBuilder();
if (ShadowType.class.equals(type)) {
ShadowType shadowType = (ShadowType) projectionType;
ResourceType resource = shadowType.getResource();
resourceName = WebComponentUtil.getName(resource);
if (shadowType.getIntent() != null) {
description.append(shadowType.getIntent()).append(", ");
}
} else if (OrgType.class.equals(type)) {
OrgType orgType = (OrgType) projectionType;
resourceName = orgType.getDisplayName() != null ? WebComponentUtil.getOrigStringFromPoly(orgType.getDisplayName()) : "";
}
description.append(WebComponentUtil.getOrigStringFromPoly(projectionType.getName()));
ObjectWrapper<S> wrapper = ObjectWrapperUtil.createObjectWrapper(resourceName, description.toString(), projection, ContainerStatus.MODIFYING, true, task, this);
wrapper.setLoadOptions(loadOptions);
wrapper.setFetchResult(OperationResult.createOperationResult(fetchResult));
wrapper.setSelectable(true);
wrapper.setMinimalized(true);
wrapper.initializeContainers(this);
subResult.computeStatus();
return new FocusSubwrapperDto<S>(wrapper, UserDtoStatus.MODIFY);
} catch (Exception ex) {
subResult.recordFatalError("Couldn't load account." + ex.getMessage(), ex);
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load account", ex);
subResult.computeStatus();
return new FocusSubwrapperDto<S>(false, resourceName, subResult);
}
}
Aggregations