use of com.evolveum.midpoint.util.exception.ObjectNotFoundException in project midpoint by Evolveum.
the class ObjectWrapperFactory method createObjectWrapper.
public <O extends ObjectType> ObjectWrapper<O> createObjectWrapper(String displayName, String description, PrismObject<O> object, ContainerStatus status, boolean delayContainerCreation, AuthorizationPhaseType authorizationPhase, Task task) {
if (authorizationPhase == null) {
authorizationPhase = AuthorizationPhaseType.REQUEST;
}
try {
// Task task = modelServiceLocator.createSimpleTask(CREATE_OBJECT_WRAPPER);
OperationResult result = task.getResult();
PrismObjectDefinition<O> objectDefinitionForEditing = modelServiceLocator.getModelInteractionService().getEditObjectDefinition(object, authorizationPhase, task, result);
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Edit definition for {}:\n{}", object, objectDefinitionForEditing.debugDump(1));
}
RefinedObjectClassDefinition objectClassDefinitionForEditing = null;
if (isShadow(object)) {
PrismReference resourceRef = object.findReference(ShadowType.F_RESOURCE_REF);
PrismObject<ResourceType> resource = resourceRef.getValue().getObject();
Validate.notNull(resource, "No resource object in the resourceRef");
objectClassDefinitionForEditing = modelServiceLocator.getModelInteractionService().getEditObjectClassDefinition((PrismObject<ShadowType>) object, resource, authorizationPhase);
}
return createObjectWrapper(displayName, description, object, objectDefinitionForEditing, objectClassDefinitionForEditing, status, delayContainerCreation, result);
} catch (SchemaException | ConfigurationException | ObjectNotFoundException ex) {
throw new SystemException(ex);
}
}
use of com.evolveum.midpoint.util.exception.ObjectNotFoundException in project midpoint by Evolveum.
the class SampleFormFocusTabPanel method initLayout.
private void initLayout(final LoadableModel<ObjectWrapper<F>> focusModel, LoadableModel<List<AssignmentEditorDto>> assignmentsModel, PageBase pageBase) {
add(new Label(ID_HEADER, "Object details"));
WebMarkupContainer body = new WebMarkupContainer("body");
add(body);
addPrismPropertyPanel(body, ID_PROP_NAME, FocusType.F_NAME);
addPrismPropertyPanel(body, ID_PROP_FULL_NAME, UserType.F_FULL_NAME);
// TODO: create proxy for these operations
Task task = pageBase.createSimpleTask(OPERATION_SEARCH_ROLES);
List<PrismObject<RoleType>> availableRoles;
try {
availableRoles = pageBase.getModelService().searchObjects(RoleType.class, null, null, task, task.getResult());
} catch (SchemaException | ObjectNotFoundException | SecurityViolationException | CommunicationException | ConfigurationException | ExpressionEvaluationException e) {
task.getResult().recordFatalError(e);
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load roles", e);
availableRoles = new ArrayList<>();
// TODO: better errror reporting
}
add(new SimpleRoleSelector<F, RoleType>(ID_ROLES, assignmentsModel, availableRoles));
}
use of com.evolveum.midpoint.util.exception.ObjectNotFoundException in project midpoint by Evolveum.
the class DefaultGuiProgressListener method getResourceName.
private String getResourceName(@NotNull String oid) {
String name = nameCache.get(oid);
if (name != null) {
return name;
}
Task task = parentPage.createSimpleTask("getResourceName");
OperationResult result = new OperationResult("getResourceName");
// todo what about security?
Collection<SelectorOptions<GetOperationOptions>> raw = SelectorOptions.createCollection(GetOperationOptions.createRaw());
try {
PrismObject<ResourceType> object = parentPage.getModelService().getObject(ResourceType.class, oid, raw, task, result);
name = PolyString.getOrig(object.asObjectable().getName());
} catch (ObjectNotFoundException | SchemaException | SecurityViolationException | CommunicationException | ConfigurationException | ExpressionEvaluationException e) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't determine the name of resource {}", e, oid);
name = "(" + oid + ")";
}
nameCache.put(oid, name);
return name;
}
use of com.evolveum.midpoint.util.exception.ObjectNotFoundException in project midpoint by Evolveum.
the class TaskCurrentStateDtoModel method refresh.
public void refresh(PageBase page) {
object = null;
if (taskModel == null || taskModel.getObject() == null) {
LOGGER.warn("Null or empty taskModel");
return;
}
TaskManager taskManager = page.getTaskManager();
OperationResult result = new OperationResult("refresh");
Task operationTask = taskManager.createTaskInstance("refresh");
String oid = taskModel.getObject().getOid();
try {
LOGGER.debug("Refreshing task {}", taskModel.getObject());
Collection<SelectorOptions<GetOperationOptions>> options = GetOperationOptions.createRetrieveAttributesOptions(TaskType.F_SUBTASK, TaskType.F_NODE_AS_OBSERVED);
PrismObject<TaskType> task = page.getModelService().getObject(TaskType.class, oid, options, operationTask, result);
TaskDto taskDto = new TaskDto(task.asObjectable(), page.getModelService(), page.getTaskService(), page.getModelInteractionService(), taskManager, page.getWorkflowManager(), TaskDtoProviderOptions.fullOptions(), operationTask, result, page);
taskModel.setObject(taskDto);
} catch (CommunicationException | ObjectNotFoundException | SchemaException | SecurityViolationException | ConfigurationException | ExpressionEvaluationException | RuntimeException e) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't refresh task {}", e, taskModel.getObject());
}
}
use of com.evolveum.midpoint.util.exception.ObjectNotFoundException in project midpoint by Evolveum.
the class AccessCertificationCloseStageTriggerHandler method handle.
@Override
public <O extends ObjectType> void handle(PrismObject<O> prismObject, TriggerType trigger, Task task, OperationResult result) {
try {
ObjectType object = prismObject.asObjectable();
if (!(object instanceof AccessCertificationCampaignType)) {
LOGGER.error("Trigger of this type is supported only on {} objects, not on {}", AccessCertificationCampaignType.class.getSimpleName(), object.getClass().getName());
return;
}
AccessCertificationCampaignType campaign = (AccessCertificationCampaignType) object;
LOGGER.info("Automatically closing current stage of {}", ObjectTypeUtil.toShortString(campaign));
if (campaign.getState() != IN_REVIEW_STAGE) {
LOGGER.warn("Campaign {} is not in a review stage; this 'close stage' trigger will be ignored.", ObjectTypeUtil.toShortString(campaign));
return;
}
int currentStageNumber = campaign.getStageNumber();
certificationManager.closeCurrentStage(campaign.getOid(), currentStageNumber, task, result);
if (currentStageNumber < CertCampaignTypeUtil.getNumberOfStages(campaign)) {
LOGGER.info("Automatically opening next stage of {}", ObjectTypeUtil.toShortString(campaign));
certificationManager.openNextStage(campaign.getOid(), currentStageNumber + 1, task, result);
} else {
LOGGER.info("Automatically starting remediation for {}", ObjectTypeUtil.toShortString(campaign));
certificationManager.startRemediation(campaign.getOid(), task, result);
}
} catch (SchemaException | ObjectNotFoundException | ObjectAlreadyExistsException | SecurityViolationException | RuntimeException e) {
LoggingUtils.logException(LOGGER, "Couldn't close current campaign and possibly advance to the next one", e);
}
}
Aggregations