use of com.evolveum.midpoint.gui.api.page.PageBase 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 fileName = "ExportedData_" + getType().getSimpleName() + "_" + System.currentTimeMillis() + "." + suffix;
File file = new File(folder, fileName);
Writer writer = null;
try {
LOGGER.debug("Creating file '{}'.", new Object[] { file.getAbsolutePath() });
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("Couldn't init download link", ex);
} finally {
if (writer != null) {
IOUtils.closeQuietly(writer);
}
}
if (!WebComponentUtil.isSuccessOrHandledError(result)) {
page.showResult(result);
page.getSession().error(page.getString("pageDebugList.message.createFileException"));
LOGGER.debug("Removing file '{}'.", new Object[] { file.getAbsolutePath() });
Files.remove(file);
throw new RestartResponseException(PageError.class);
}
return file;
}
use of com.evolveum.midpoint.gui.api.page.PageBase in project midpoint by Evolveum.
the class PageDebugDownloadBehaviour method dumpObjectsToStream.
private <T extends ObjectType> void dumpObjectsToStream(final Writer writer, OperationResult result) throws Exception {
final PageBase page = getPage();
ResultHandler handler = new ResultHandler() {
@Override
public boolean handle(PrismObject object, OperationResult parentResult) {
try {
String xml = page.getPrismContext().serializeObjectToString(object, PrismContext.LANG_XML);
writer.write('\t');
writer.write(xml);
writer.write('\n');
} catch (IOException ex) {
throw new SystemException(ex.getMessage(), ex);
} catch (SchemaException ex) {
throw new SystemException(ex.getMessage(), ex);
}
return true;
}
};
ModelService service = page.getModelService();
GetOperationOptions options = GetOperationOptions.createRaw();
options.setResolveNames(true);
service.searchObjectsIterative(type, query, handler, SelectorOptions.createCollection(options), page.createSimpleTask(OPERATION_SEARCH_OBJECT), result);
}
use of com.evolveum.midpoint.gui.api.page.PageBase in project midpoint by Evolveum.
the class OrgTreeAssignablePanel method initLayout.
private void initLayout() {
AbstractOrgTabPanel tabbedPanel = new AbstractOrgTabPanel(ID_ORG_TABS, getPageBase()) {
private static final long serialVersionUID = 1L;
@Override
protected Panel createTreePanel(String id, Model<String> model, PageBase pageBase) {
OrgTreePanel panel = new OrgTreePanel(id, model, selectable) {
private static final long serialVersionUID = 1L;
@Override
protected void selectTreeItemPerformed(SelectableBean<OrgType> selected, AjaxRequestTarget target) {
onItemSelect(selected, target);
}
};
panel.setOutputMarkupId(true);
return panel;
}
};
tabbedPanel.setOutputMarkupId(true);
add(tabbedPanel);
AjaxButton assignButton = new AjaxButton(ID_ASSIGN, getPageBase().createStringResource("Button.assign")) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
AbstractOrgTabPanel orgPanel = (AbstractOrgTabPanel) getParent().get(ID_ORG_TABS);
OrgTreePanel treePanel = (OrgTreePanel) orgPanel.getPanel();
List<OrgType> selectedOrgs = treePanel.getSelectedOrgs();
assignSelectedOrgPerformed(selectedOrgs, target);
}
};
assignButton.setOutputMarkupId(true);
assignButton.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return selectable;
}
});
add(assignButton);
}
use of com.evolveum.midpoint.gui.api.page.PageBase in project midpoint by Evolveum.
the class AsyncDashboardPanel method onUpdateError.
@Override
protected void onUpdateError(AjaxRequestTarget target, Exception ex) {
String message = "Error occurred while fetching data: " + ex.getMessage();
Label errorLabel = new Label(ID_CONTENT, message);
WebMarkupContainer dashboardContent = getDashboardContent();
dashboardContent.replace(errorLabel);
PageBase page = (PageBase) getPage();
showResultIfError(page);
target.add(this, page.getFeedbackPanel());
}
use of com.evolveum.midpoint.gui.api.page.PageBase in project midpoint by Evolveum.
the class AbstractTreeTablePanel method refreshTabbedPanel.
protected void refreshTabbedPanel(AjaxRequestTarget target) {
PageBase page = getPageBase();
TabbedPanel tabbedPanel = findParent(TabbedPanel.class);
IModel<List<ITab>> tabs = tabbedPanel.getTabs();
if (tabs instanceof LoadableModel) {
((LoadableModel) tabs).reset();
}
if (tabs.getObject() != null && tabs.getObject().size() > 0) {
tabbedPanel.setSelectedTab(0);
}
target.add(tabbedPanel);
target.add(page.getFeedbackPanel());
}
Aggregations