use of org.apache.wicket.RestartResponseException in project midpoint by Evolveum.
the class PageCaseWorkItem method loadCaseIfNecessary.
private CaseType loadCaseIfNecessary() {
if (caseModel.isLoaded()) {
return caseModel.getObject();
}
Task task = createSimpleTask(OPERATION_LOAD_CASE);
OperationResult result = task.getResult();
CaseType caseInstance = null;
try {
PrismObject<CaseType> caseObject = // optionsBuilder.build(),
WebModelServiceUtils.loadObject(// optionsBuilder.build(),
CaseType.class, // optionsBuilder.build(),
workItemId.getCaseOid(), // optionsBuilder.build(),
null, PageCaseWorkItem.this, task, result);
caseInstance = caseObject.asObjectable();
result.recordSuccessIfUnknown();
} catch (RestartResponseException e) {
// already processed
throw e;
} catch (NullPointerException ex) {
result.recordFatalError(getString("PageCaseWorkItem.couldNotGetCase"), ex);
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't get case because it does not exist. (It might have been already completed or deleted.)", ex);
} catch (RuntimeException ex) {
result.recordFatalError(getString("PageCaseWorkItem.couldNotGetCase.runtime"), ex);
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't get case.", ex);
}
showResult(result, false);
if (!result.isSuccess()) {
throw redirectBackViaRestartResponseException();
}
return caseInstance;
}
use of org.apache.wicket.RestartResponseException in project midpoint by Evolveum.
the class PageDebugDownloadBehaviour method initFile.
@Override
protected File initFile() {
PageBase page = getPage();
OperationResult result = new OperationResult(OPERATION_CREATE_DOWNLOAD_FILE);
MidPointApplication application = page.getMidpointApplication();
WebApplicationConfiguration config = application.getWebApplicationConfiguration();
File folder = new File(config.getExportFolder());
if (!folder.exists() || !folder.isDirectory()) {
folder.mkdir();
}
String suffix = isUseZip() ? "zip" : "xml";
String currentTime = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy_MM_dd_HH_m_s"));
String fileName = "ExportedData_" + getType().getSimpleName() + "_" + currentTime + "." + suffix;
File file = new File(folder, fileName);
LOGGER.debug("Creating file '{}'.", file.getAbsolutePath());
try (Writer writer = createWriter(file)) {
LOGGER.debug("Exporting objects.");
dumpHeader(writer);
dumpObjectsToStream(writer, result);
dumpFooter(writer);
LOGGER.debug("Export finished.");
result.recomputeStatus();
} catch (Exception ex) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't init download link", ex);
result.recordFatalError(getPage().createStringResource("PageDebugDownloadBehaviour.message.initFile.fatalError").getString(), ex);
}
if (!WebComponentUtil.isSuccessOrHandledError(result)) {
page.showResult(result);
page.getSession().error(page.getString("pageDebugList.message.createFileException"));
LOGGER.debug("Removing file '{}'.", file.getAbsolutePath());
Files.remove(file);
throw new RestartResponseException(PageDebugList.class);
}
return file;
}
use of org.apache.wicket.RestartResponseException in project midpoint by Evolveum.
the class ObjectDataProvider method internalSize.
@Override
protected int internalSize() {
LOGGER.trace("begin::internalSize()");
int count = 0;
OperationResult result = new OperationResult(OPERATION_COUNT_OBJECTS);
try {
Task task = getPageBase().createSimpleTask(OPERATION_COUNT_OBJECTS);
count = getModel().countObjects(getType(), getQuery(), getOptionsToUse(), task, result);
} catch (Exception ex) {
result.recordFatalError(getPageBase().createStringResource("ObjectDataProvider.message.countObjects.fatalError").getString(), ex);
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't count objects", ex);
} finally {
result.computeStatusIfUnknown();
}
if (!WebComponentUtil.isSuccessOrHandledError(result) && !OperationResultStatus.NOT_APPLICABLE.equals(result.getStatus())) {
getPageBase().showResult(result);
throw new RestartResponseException(PageError.class);
}
LOGGER.trace("end::internalSize(): {}", count);
return count;
}
use of org.apache.wicket.RestartResponseException in project midpoint by Evolveum.
the class PageSelfRegistration method prepareUserToSave.
private UserType prepareUserToSave(Task task, OperationResult result) throws ExpressionEvaluationException, SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException {
SelfRegistrationDto selfRegistrationConfiguration = getSelfRegistrationConfiguration();
UserType userType = getUserModel().getObject();
UserType userToSave = userType.clone();
if (!isCustomFormDefined()) {
applyPassword(userToSave);
if (selfRegistrationConfiguration.getRequiredLifecycleState() != null) {
String userLifecycle = userToSave.getLifecycleState();
if (!selfRegistrationConfiguration.getRequiredLifecycleState().equals(userLifecycle)) {
LOGGER.error("Registration not allowed for a user {} -> Unsatisfied Configuration for required lifecycle, expected {} but was {}", userToSave.getEmailAddress() != null ? userToSave.getEmailAddress() : userToSave, selfRegistrationConfiguration.getRequiredLifecycleState(), userLifecycle);
getSession().error(createStringResource("PageSelfRegistration.registration.failed.unsatisfied.registration.configuration").getString());
throw new RestartResponseException(this);
}
}
} else {
try {
userToSave = getDynamicFormPanel().getObject().asObjectable().clone();
} catch (SchemaException e) {
LoggingUtils.logException(LOGGER, "Failed to construct delta " + e.getMessage(), e);
throw new RestartResponseException(this);
}
}
// CredentialsType credentials =
applyNonce(userToSave, selfRegistrationConfiguration.getNoncePolicy(), task, result);
// userToSave.setCredentials(credentials);
if (selfRegistrationConfiguration.getInitialLifecycleState() != null) {
LOGGER.trace("Setting initial lifecycle state of registered user to {}", selfRegistrationConfiguration.getInitialLifecycleState());
userToSave.setLifecycleState(selfRegistrationConfiguration.getInitialLifecycleState());
}
try {
getPrismContext().adopt(userToSave);
} catch (SchemaException e) {
// nothing to do, try without it
}
return userToSave;
}
use of org.apache.wicket.RestartResponseException in project midpoint by Evolveum.
the class PageSelfRegistration method createUserModel.
private UserType createUserModel(String userOid) {
if (userOid == null) {
LOGGER.trace("Registration process for new user started");
return instantiateUser();
}
PrismObject<UserType> result = runPrivileged(new Producer<PrismObject<UserType>>() {
private static final long serialVersionUID = 1L;
@Override
public PrismObject<UserType> run() {
LOGGER.trace("Loading preregistered user with oid {}.", userOid);
Task task = createAnonymousTask(OPERATION_LOAD_USER);
OperationResult result = new OperationResult(OPERATION_LOAD_USER);
PrismObject<UserType> user = WebModelServiceUtils.loadObject(UserType.class, userOid, PageSelfRegistration.this, task, result);
result.computeStatus();
return user;
}
});
if (result == null) {
LOGGER.error("Failed to load preregistered user");
getSession().error(createStringResource("PageSelfRegistration.invalid.registration.link").getString());
throw new RestartResponseException(PageLogin.class);
}
return result.asObjectable();
}
Aggregations