Search in sources :

Example 31 with PageBase

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;
}
Also used : MidPointApplication(com.evolveum.midpoint.web.security.MidPointApplication) RestartResponseException(org.apache.wicket.RestartResponseException) WebApplicationConfiguration(com.evolveum.midpoint.web.security.WebApplicationConfiguration) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PageBase(com.evolveum.midpoint.gui.api.page.PageBase) File(org.apache.wicket.util.file.File) AjaxDownloadBehaviorFromFile(com.evolveum.midpoint.web.component.AjaxDownloadBehaviorFromFile) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) RestartResponseException(org.apache.wicket.RestartResponseException) SystemException(com.evolveum.midpoint.util.exception.SystemException)

Example 32 with PageBase

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);
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) GetOperationOptions(com.evolveum.midpoint.schema.GetOperationOptions) SystemException(com.evolveum.midpoint.util.exception.SystemException) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResultHandler(com.evolveum.midpoint.schema.ResultHandler) PageBase(com.evolveum.midpoint.gui.api.page.PageBase) ModelService(com.evolveum.midpoint.model.api.ModelService)

Example 33 with PageBase

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);
}
Also used : PageBase(com.evolveum.midpoint.gui.api.page.PageBase) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) OrgType(com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType) StringResourceModel(org.apache.wicket.model.StringResourceModel) Model(org.apache.wicket.model.Model) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)

Example 34 with PageBase

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());
}
Also used : Label(org.apache.wicket.markup.html.basic.Label) PageBase(com.evolveum.midpoint.gui.api.page.PageBase) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer)

Example 35 with PageBase

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());
}
Also used : LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) List(java.util.List) TabbedPanel(com.evolveum.midpoint.web.component.TabbedPanel) PageBase(com.evolveum.midpoint.gui.api.page.PageBase)

Aggregations

PageBase (com.evolveum.midpoint.gui.api.page.PageBase)44 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)16 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)13 Task (com.evolveum.midpoint.task.api.Task)9 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)7 SystemException (com.evolveum.midpoint.util.exception.SystemException)6 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)5 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)5 ModelService (com.evolveum.midpoint.model.api.ModelService)4 PrismObject (com.evolveum.midpoint.prism.PrismObject)4 SelectorOptions (com.evolveum.midpoint.schema.SelectorOptions)4 ConfirmationPanel (com.evolveum.midpoint.web.component.dialog.ConfirmationPanel)4 PageParameters (org.apache.wicket.request.mapper.parameter.PageParameters)4 PrismContext (com.evolveum.midpoint.prism.PrismContext)3 EncryptionException (com.evolveum.midpoint.prism.crypto.EncryptionException)3 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)3 ResourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 RestartResponseException (org.apache.wicket.RestartResponseException)3