Example usage for com.vaadin.server VaadinService getCurrentRequest

List of usage examples for com.vaadin.server VaadinService getCurrentRequest

Introduction

In this page you can find the example usage for com.vaadin.server VaadinService getCurrentRequest.

Prototype

public static VaadinRequest getCurrentRequest() 

Source Link

Document

Gets the currently processed Vaadin request.

Usage

From source file:org.ikasan.dashboard.ui.topology.window.ExclusionEventViewWindow.java

License:BSD License

protected Panel createExclusionEventDetailsPanel() {
    Panel exclusionEventDetailsPanel = new Panel();
    exclusionEventDetailsPanel.setSizeFull();
    exclusionEventDetailsPanel.setStyleName("dashboard");

    GridLayout layout = new GridLayout(4, 7);
    layout.setSpacing(true);/*from ww w  . j  a va 2s  . c o m*/
    layout.setColumnExpandRatio(0, .10f);
    layout.setColumnExpandRatio(1, .30f);
    layout.setColumnExpandRatio(2, .05f);
    layout.setColumnExpandRatio(3, .30f);

    layout.setWidth("100%");

    Label exclusionEvenDetailsLabel = new Label("Exclusion Event Details");
    exclusionEvenDetailsLabel.setStyleName(ValoTheme.LABEL_HUGE);
    layout.addComponent(exclusionEvenDetailsLabel, 0, 0, 3, 0);

    Label label = new Label("Module Name:");
    label.setSizeUndefined();
    layout.addComponent(label, 0, 1);
    layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT);

    TextField tf1 = new TextField();
    tf1.setValue(this.exclusionEvent.getModuleName());
    tf1.setReadOnly(true);
    tf1.setWidth("80%");
    layout.addComponent(tf1, 1, 1);

    label = new Label("Flow Name:");
    label.setSizeUndefined();
    layout.addComponent(label, 0, 2);
    layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT);

    TextField tf2 = new TextField();
    tf2.setValue(this.exclusionEvent.getFlowName());
    tf2.setReadOnly(true);
    tf2.setWidth("80%");
    layout.addComponent(tf2, 1, 2);

    label = new Label("Event Id:");
    label.setSizeUndefined();
    layout.addComponent(label, 0, 3);
    layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT);

    TextField tf3 = new TextField();
    tf3.setValue(this.errorOccurrence.getEventLifeIdentifier());
    tf3.setReadOnly(true);
    tf3.setWidth("80%");
    layout.addComponent(tf3, 1, 3);

    label = new Label("Date/Time:");
    label.setSizeUndefined();
    layout.addComponent(label, 0, 4);
    layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT);

    TextField tf4 = new TextField();
    tf4.setValue(new Date(this.exclusionEvent.getTimestamp()).toString());
    tf4.setReadOnly(true);
    tf4.setWidth("80%");
    layout.addComponent(tf4, 1, 4);

    label = new Label("Error URI:");
    label.setSizeUndefined();
    layout.addComponent(label, 0, 5);
    layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT);

    TextField tf5 = new TextField();
    tf5.setValue(exclusionEvent.getErrorUri());
    tf5.setReadOnly(true);
    tf5.setWidth("80%");
    layout.addComponent(tf5, 1, 5);

    label = new Label("Action:");
    label.setSizeUndefined();
    layout.addComponent(label, 2, 1);
    layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT);

    final TextField tf6 = new TextField();
    if (this.action != null) {
        tf6.setValue(action.getAction());
    }
    tf6.setReadOnly(true);
    tf6.setWidth("80%");
    layout.addComponent(tf6, 3, 1);

    label = new Label("Actioned By:");
    label.setSizeUndefined();
    layout.addComponent(label, 2, 2);
    layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT);

    final TextField tf7 = new TextField();
    if (this.action != null) {
        tf7.setValue(action.getActionedBy());
    }
    tf7.setReadOnly(true);
    tf7.setWidth("80%");
    layout.addComponent(tf7, 3, 2);

    label = new Label("Actioned Time:");
    label.setSizeUndefined();
    layout.addComponent(label, 2, 3);
    layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT);

    final TextField tf8 = new TextField();
    if (this.action != null) {
        tf8.setValue(new Date(action.getTimestamp()).toString());
    }
    tf8.setReadOnly(true);
    tf8.setWidth("80%");
    layout.addComponent(tf8, 3, 3);

    final Button resubmitButton = new Button("Re-submit");
    final Button ignoreButton = new Button("Ignore");

    resubmitButton.addClickListener(new Button.ClickListener() {
        @SuppressWarnings("unchecked")
        public void buttonClick(ClickEvent event) {
            IkasanAuthentication authentication = (IkasanAuthentication) VaadinService.getCurrentRequest()
                    .getWrappedSession().getAttribute(DashboardSessionValueConstants.USER);

            HttpAuthenticationFeature feature = HttpAuthenticationFeature.basic(authentication.getName(),
                    (String) authentication.getCredentials());

            ClientConfig clientConfig = new ClientConfig();
            clientConfig.register(feature);

            Client client = ClientBuilder.newClient(clientConfig);

            Module module = topologyService.getModuleByName(exclusionEvent.getModuleName());

            if (module == null) {
                Notification
                        .show("Unable to find server information for module we are attempting to re-submit to: "
                                + exclusionEvent.getModuleName(), Type.ERROR_MESSAGE);

                return;
            }

            Server server = module.getServer();

            String url = "http://" + server.getUrl() + ":" + server.getPort() + module.getContextRoot()
                    + "/rest/resubmission/resubmit/" + exclusionEvent.getModuleName() + "/"
                    + exclusionEvent.getFlowName() + "/" + exclusionEvent.getErrorUri();

            logger.info("Resubmission Url: " + url);

            WebTarget webTarget = client.target(url);
            Response response = webTarget.request()
                    .put(Entity.entity(exclusionEvent.getEvent(), MediaType.APPLICATION_OCTET_STREAM));

            if (response.getStatus() != 200) {
                response.bufferEntity();

                String responseMessage = response.readEntity(String.class);
                Notification.show("An error was received trying to resubmit event: " + responseMessage,
                        Type.ERROR_MESSAGE);
            } else {
                Notification.show("Event resumitted successfully.");
                resubmitButton.setVisible(false);
                ignoreButton.setVisible(false);

                ExclusionEventAction action = hospitalManagementService
                        .getExclusionEventActionByErrorUri(exclusionEvent.getErrorUri());
                tf6.setReadOnly(false);
                tf7.setReadOnly(false);
                tf8.setReadOnly(false);
                tf6.setValue(action.getAction());
                tf7.setValue(action.getActionedBy());
                tf8.setValue(new Date(action.getTimestamp()).toString());
                tf6.setReadOnly(true);
                tf7.setReadOnly(true);
                tf8.setReadOnly(true);
            }
        }
    });

    ignoreButton.addClickListener(new Button.ClickListener() {
        @SuppressWarnings("unchecked")
        public void buttonClick(ClickEvent event) {
            IkasanAuthentication authentication = (IkasanAuthentication) VaadinService.getCurrentRequest()
                    .getWrappedSession().getAttribute(DashboardSessionValueConstants.USER);

            HttpAuthenticationFeature feature = HttpAuthenticationFeature.basic(authentication.getName(),
                    (String) authentication.getCredentials());

            ClientConfig clientConfig = new ClientConfig();
            clientConfig.register(feature);

            Client client = ClientBuilder.newClient(clientConfig);

            Module module = topologyService.getModuleByName(exclusionEvent.getModuleName());

            if (module == null) {
                Notification
                        .show("Unable to find server information for module we are submitting the ignore to: "
                                + exclusionEvent.getModuleName(), Type.ERROR_MESSAGE);

                return;
            }

            Server server = module.getServer();

            String url = "http://" + server.getUrl() + ":" + server.getPort() + module.getContextRoot()
                    + "/rest/resubmission/ignore/" + exclusionEvent.getModuleName() + "/"
                    + exclusionEvent.getFlowName() + "/" + exclusionEvent.getErrorUri();

            logger.info("Ignore Url: " + url);

            WebTarget webTarget = client.target(url);
            Response response = webTarget.request()
                    .put(Entity.entity(exclusionEvent.getEvent(), MediaType.APPLICATION_OCTET_STREAM));

            if (response.getStatus() != 200) {
                response.bufferEntity();

                String responseMessage = response.readEntity(String.class);
                Notification.show("An error was received trying to resubmit event: " + responseMessage,
                        Type.ERROR_MESSAGE);
            } else {
                Notification.show("Event ignored successfully.");
                resubmitButton.setVisible(false);
                ignoreButton.setVisible(false);

                ExclusionEventAction action = hospitalManagementService
                        .getExclusionEventActionByErrorUri(exclusionEvent.getErrorUri());
                tf6.setReadOnly(false);
                tf7.setReadOnly(false);
                tf8.setReadOnly(false);
                tf6.setValue(action.getAction());
                tf7.setValue(action.getActionedBy());
                tf8.setValue(new Date(action.getTimestamp()).toString());
                tf6.setReadOnly(true);
                tf7.setReadOnly(true);
                tf8.setReadOnly(true);
            }
        }
    });

    HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setHeight("100%");
    buttonLayout.setSpacing(true);
    buttonLayout.setWidth(200, Unit.PIXELS);
    buttonLayout.setMargin(true);
    buttonLayout.addComponent(resubmitButton);
    buttonLayout.addComponent(ignoreButton);

    if (this.action == null) {
        layout.addComponent(buttonLayout, 0, 6, 3, 6);
        layout.setComponentAlignment(buttonLayout, Alignment.MIDDLE_CENTER);
    }

    final IkasanAuthentication authentication = (IkasanAuthentication) VaadinService.getCurrentRequest()
            .getWrappedSession().getAttribute(DashboardSessionValueConstants.USER);

    if (authentication != null && (!authentication.hasGrantedAuthority(SecurityConstants.ALL_AUTHORITY)
            && !authentication.hasGrantedAuthority(SecurityConstants.ACTION_EXCLUSIONS_AUTHORITY))) {
        resubmitButton.setVisible(false);
        ignoreButton.setVisible(false);
    }

    AceEditor eventEditor = new AceEditor();
    eventEditor.setCaption("Event Payload");
    logger.info("Setting exclusion event to: " + new String(this.exclusionEvent.getEvent()));
    Object event = this.serialiserFactory.getDefaultSerialiser().deserialise(this.exclusionEvent.getEvent());
    eventEditor.setValue(event.toString());
    eventEditor.setReadOnly(true);
    eventEditor.setMode(AceMode.java);
    eventEditor.setTheme(AceTheme.eclipse);
    eventEditor.setWidth("100%");
    eventEditor.setHeight(600, Unit.PIXELS);

    HorizontalLayout eventEditorLayout = new HorizontalLayout();
    eventEditorLayout.setSizeFull();
    eventEditorLayout.setMargin(true);
    eventEditorLayout.addComponent(eventEditor);

    AceEditor errorEditor = new AceEditor();
    errorEditor.setCaption("Error Details");
    errorEditor.setValue(this.errorOccurrence.getErrorDetail());
    errorEditor.setReadOnly(true);
    errorEditor.setMode(AceMode.xml);
    errorEditor.setTheme(AceTheme.eclipse);
    errorEditor.setWidth("100%");
    errorEditor.setHeight(600, Unit.PIXELS);

    HorizontalLayout errorEditorLayout = new HorizontalLayout();
    errorEditorLayout.setSizeFull();
    errorEditorLayout.setMargin(true);
    errorEditorLayout.addComponent(errorEditor);

    VerticalSplitPanel splitPanel = new VerticalSplitPanel();
    splitPanel.addStyleName(ValoTheme.SPLITPANEL_LARGE);
    splitPanel.setWidth("100%");
    splitPanel.setHeight(800, Unit.PIXELS);

    HorizontalLayout h1 = new HorizontalLayout();
    h1.setSizeFull();
    h1.setMargin(true);
    h1.addComponent(eventEditorLayout);
    splitPanel.setFirstComponent(eventEditorLayout);

    HorizontalLayout h2 = new HorizontalLayout();
    h2.setSizeFull();
    h2.setMargin(true);
    h2.addComponent(errorEditorLayout);
    splitPanel.setSecondComponent(errorEditorLayout);

    HorizontalLayout formLayout = new HorizontalLayout();
    formLayout.setWidth("100%");
    formLayout.setHeight(240, Unit.PIXELS);
    formLayout.addComponent(layout);

    GridLayout wrapperLayout = new GridLayout(1, 4);
    wrapperLayout.setMargin(true);
    wrapperLayout.setWidth("100%");
    wrapperLayout.addComponent(formLayout);
    wrapperLayout.addComponent(splitPanel);

    exclusionEventDetailsPanel.setContent(wrapperLayout);
    return exclusionEventDetailsPanel;
}

From source file:org.ikasan.dashboard.ui.topology.window.StartupControlConfigurationWindow.java

License:BSD License

/**
  * Helper method to initialise this object.
  * /*from   ww w. j  av  a  2  s.  co  m*/
  * @param message
  */
protected void init() {
    setModal(true);
    setResizable(false);
    setHeight("320px");
    setWidth("550px");

    GridLayout gridLayout = new GridLayout(2, 6);
    gridLayout.setWidth("500px");
    gridLayout.setColumnExpandRatio(0, .15f);
    gridLayout.setColumnExpandRatio(1, .85f);

    gridLayout.setSpacing(true);
    gridLayout.setMargin(true);

    Label startupControlLabel = new Label("Startup Control");
    startupControlLabel.addStyleName(ValoTheme.LABEL_HUGE);

    gridLayout.addComponent(startupControlLabel, 0, 0, 1, 0);

    Label moduleNameLabel = new Label();
    moduleNameLabel.setContentMode(ContentMode.HTML);
    moduleNameLabel.setValue(VaadinIcons.ARCHIVE.getHtml() + " Module Name:");
    moduleNameLabel.setSizeUndefined();
    gridLayout.addComponent(moduleNameLabel, 0, 1);
    gridLayout.setComponentAlignment(moduleNameLabel, Alignment.MIDDLE_RIGHT);

    startupControl = this.startupControlService.getStartupControl(flow.getModule().getName(), flow.getName());

    startupControlItem = new BeanItem<StartupControl>(startupControl);

    moduleNameTextField = new TextField();
    moduleNameTextField.setRequired(true);
    moduleNameTextField.setPropertyDataSource(startupControlItem.getItemProperty("moduleName"));
    moduleNameTextField.setReadOnly(true);
    moduleNameTextField.setWidth("90%");
    gridLayout.addComponent(moduleNameTextField, 1, 1);

    Label flowNameLabel = new Label();
    flowNameLabel.setContentMode(ContentMode.HTML);
    flowNameLabel.setValue(VaadinIcons.AUTOMATION.getHtml() + " Flow Name:");
    flowNameLabel.setSizeUndefined();
    gridLayout.addComponent(flowNameLabel, 0, 2);
    gridLayout.setComponentAlignment(flowNameLabel, Alignment.MIDDLE_RIGHT);

    flowNameTextField = new TextField();
    flowNameTextField.setRequired(true);
    flowNameTextField.setPropertyDataSource(startupControlItem.getItemProperty("flowName"));
    flowNameTextField.setReadOnly(true);
    flowNameTextField.setWidth("90%");
    gridLayout.addComponent(flowNameTextField, 1, 2);

    Label startupTypeLabel = new Label("Startup Type:");
    startupTypeLabel.setSizeUndefined();
    this.startupType = new ComboBox();
    this.startupType.addItem(StartupType.MANUAL);
    this.startupType.setItemCaption(StartupType.MANUAL, "Manual");
    this.startupType.addItem(StartupType.AUTOMATIC);
    this.startupType.setItemCaption(StartupType.AUTOMATIC, "Automatic");
    this.startupType.addItem(StartupType.DISABLED);
    this.startupType.setItemCaption(StartupType.DISABLED, "Disabled");
    this.startupType.setPropertyDataSource(startupControlItem.getItemProperty("startupType"));
    this.startupType.setNullSelectionAllowed(false);

    this.startupType.addValidator(new StringLengthValidator("A name must be entered.", 1, null, false));
    this.startupType.setWidth("90%");
    this.startupType.setValidationVisible(false);

    gridLayout.addComponent(startupTypeLabel, 0, 3);
    gridLayout.setComponentAlignment(startupTypeLabel, Alignment.MIDDLE_RIGHT);
    gridLayout.addComponent(this.startupType, 1, 3);

    Label commentLabel = new Label("Comment:");
    commentLabel.setSizeUndefined();
    this.comment = new TextArea();
    this.comment.setRows(3);
    this.comment.addValidator(new StringLengthValidator("A name must be entered.", 1, null, false));
    this.comment.setWidth("90%");
    this.comment.setValidationVisible(false);
    this.comment.setNullRepresentation("");
    this.comment.setPropertyDataSource(startupControlItem.getItemProperty("comment"));

    gridLayout.addComponent(commentLabel, 0, 4);
    gridLayout.setComponentAlignment(commentLabel, Alignment.MIDDLE_RIGHT);
    gridLayout.addComponent(this.comment, 1, 4);

    Button saveButton = new Button("Save");
    Button cancelButton = new Button("Cancel");

    GridLayout buttonLayout = new GridLayout(2, 1);
    buttonLayout.setSpacing(true);

    buttonLayout.addComponent(saveButton);
    buttonLayout.setComponentAlignment(saveButton, Alignment.MIDDLE_CENTER);
    buttonLayout.addComponent(cancelButton);
    buttonLayout.setComponentAlignment(cancelButton, Alignment.MIDDLE_CENTER);

    gridLayout.addComponent(buttonLayout, 0, 5, 1, 5);
    gridLayout.setComponentAlignment(buttonLayout, Alignment.MIDDLE_CENTER);

    saveButton.addClickListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            StartupControl sc = startupControlItem.getBean();

            if (((StartupType) startupType.getValue()) == StartupType.DISABLED
                    && (comment.getValue() == null || comment.getValue().length() == 0)) {
                Notification.show("A comment must be entered for a 'Disabled' start up type!",
                        Type.ERROR_MESSAGE);

                return;
            } else {
                final IkasanAuthentication authentication = (IkasanAuthentication) VaadinService
                        .getCurrentRequest().getWrappedSession()
                        .getAttribute(DashboardSessionValueConstants.USER);

                StartupControlConfigurationWindow.this.startupControlService.setStartupType(sc.getModuleName(),
                        sc.getFlowName(), (StartupType) startupType.getValue(), comment.getValue(),
                        authentication.getName());

                Notification.show("Saved!");
            }
        }
    });

    cancelButton.addClickListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            UI.getCurrent().removeWindow(StartupControlConfigurationWindow.this);
        }
    });

    this.setContent(gridLayout);
}

From source file:org.ikasan.dashboard.ui.topology.window.WiretapConfigurationWindow.java

License:BSD License

protected void createWiretap(String relationship, String jobType, String timeToLive) {
    IkasanAuthentication authentication = (IkasanAuthentication) VaadinService.getCurrentRequest()
            .getWrappedSession().getAttribute(DashboardSessionValueConstants.USER);

    HttpAuthenticationFeature feature = HttpAuthenticationFeature.basic(authentication.getName(),
            (String) authentication.getCredentials());

    ClientConfig clientConfig = new ClientConfig();
    clientConfig.register(feature);/*w  w w . j a  va2s. c  o m*/

    Client client = ClientBuilder.newClient(clientConfig);

    Server server = this.component.getFlow().getModule().getServer();

    String url = "http://" + server.getUrl() + ":" + server.getPort()
            + this.component.getFlow().getModule().getContextRoot() + "/rest/wiretap/createTrigger/"
            + this.component.getFlow().getModule().getName() + "/" + this.component.getFlow().getName() + "/"
            + this.component.getName() + "/" + relationship + "/" + jobType;

    logger.info("Resubmission Url: " + url);

    WebTarget webTarget = client.target(url);
    Response response = webTarget.request().put(Entity.entity(timeToLive, MediaType.APPLICATION_OCTET_STREAM));

    if (response.getStatus() != 200) {
        response.bufferEntity();

        String responseMessage = response.readEntity(String.class);

        logger.error("An error occurred trying to create a wiretap: " + responseMessage);
        Notification.show("An error was received trying to create a wiretap: " + responseMessage,
                Type.ERROR_MESSAGE);
    } else {
        Notification.show("Wiretap created successfully!");

        this.refreshTriggerTable();
    }
}

From source file:org.ikasan.dashboard.ui.topology.window.WiretapConfigurationWindow.java

License:BSD License

protected void deleteWiretap(Long triggerId) {
    IkasanAuthentication authentication = (IkasanAuthentication) VaadinService.getCurrentRequest()
            .getWrappedSession().getAttribute(DashboardSessionValueConstants.USER);

    HttpAuthenticationFeature feature = HttpAuthenticationFeature.basic(authentication.getName(),
            (String) authentication.getCredentials());

    ClientConfig clientConfig = new ClientConfig();
    clientConfig.register(feature);//www .j  a  v a2 s .c o m

    Client client = ClientBuilder.newClient(clientConfig);

    Server server = this.component.getFlow().getModule().getServer();

    String url = "http://" + server.getUrl() + ":" + server.getPort()
            + this.component.getFlow().getModule().getContextRoot() + "/rest/wiretap/deleteTrigger";

    logger.info("Resubmission Url: " + url);

    WebTarget webTarget = client.target(url);
    Response response = webTarget.request().put(Entity.entity(triggerId, MediaType.APPLICATION_JSON));

    if (response.getStatus() != 200) {
        response.bufferEntity();

        String responseMessage = response.readEntity(String.class);

        logger.error("An error occurred trying to delete a wiretap: " + responseMessage);
        Notification.show("An error was received trying to delete a wiretap: " + responseMessage,
                Type.ERROR_MESSAGE);
    } else {
        Notification.show("Wiretap deleted successfully!");

        this.refreshTriggerTable();
    }
}

From source file:org.inakirj.imagerulette.utils.CookieManager.java

License:Open Source License

/**
 * Match cookie or create a new one.//ww w. j av a  2 s .c  o  m
 */
private void matchCookie() {
    Cookie[] cookies = VaadinService.getCurrentRequest().getCookies();
    if (cookies == null) {
        appCookie = createCookie();
    } else {
        for (Cookie cookie : cookies) {
            if (COOKIE_ID.equals(cookie.getName())) {
                appCookie = cookie;
                break;
            }
        }
        if (appCookie == null) {
            appCookie = createCookie();
        }
    }
}

From source file:org.opencms.ui.A_CmsUI.java

License:Open Source License

/**
 * Returns the workplace settings.<p>
 *
 * @return the workplace settings/*from  w  ww  . j a v a  2  s .  co m*/
 */
public CmsWorkplaceSettings getWorkplaceSettings() {

    CmsWorkplaceSettings settings = (CmsWorkplaceSettings) getSession().getSession()
            .getAttribute(CmsWorkplaceManager.SESSION_WORKPLACE_SETTINGS);
    if (settings == null) {
        settings = CmsLoginHelper.initSiteAndProject(getCmsObject());
        VaadinService.getCurrentRequest().getWrappedSession()
                .setAttribute(CmsWorkplaceManager.SESSION_WORKPLACE_SETTINGS, settings);
    }
    return settings;
}

From source file:org.opencms.ui.CmsVaadinUtils.java

License:Open Source License

/**
 * Gets the current Vaadin request, cast to a HttpServletRequest.<p>
 *
 * @return the current request/* ww w .  ja  v  a2 s  .  c o  m*/
 */
public static HttpServletRequest getRequest() {

    return (HttpServletRequest) VaadinService.getCurrentRequest();
}

From source file:org.opencms.ui.components.extensions.CmsGwtDialogExtension.java

License:Open Source License

/**
 * Gets the publish data for the given project.<p>
 *
 * @param project the project to open publish dialog for
 *
 * @return the publish data/*w  w  w .ja  v a 2  s . c om*/
 */
protected CmsPublishData getPublishData(CmsProject project) {

    CmsPublishService publishService = new CmsPublishService();
    CmsObject cms = A_CmsUI.getCmsObject();
    publishService.setCms(cms);
    publishService.setRequest((HttpServletRequest) (VaadinService.getCurrentRequest()));
    try {
        return publishService.getPublishData(cms, new HashMap<String, String>()/*params*/, null/*workflowId*/,
                "" + project.getUuid()/*projectParam*/, new ArrayList<String>(), null/*closelink*/,
                false/*confirmation*/);
    } catch (Exception e) {
        LOG.error(e.getLocalizedMessage(), e);
        return null;
    }
}

From source file:org.opencms.ui.components.extensions.CmsGwtDialogExtension.java

License:Open Source License

/**
 * Gets the publish data for the given resources.<p>
 *
 * @param directPublishResources the resources to publish
 *
 * @return the publish data for the resources
 *///from  ww w  . jav  a2s.  c o  m
protected CmsPublishData getPublishData(List<CmsResource> directPublishResources) {

    CmsPublishService publishService = new CmsPublishService();
    CmsObject cms = A_CmsUI.getCmsObject();
    publishService.setCms(cms);
    List<String> pathList = Lists.newArrayList();
    for (CmsResource resource : directPublishResources) {
        pathList.add(cms.getSitePath(resource));
    }
    publishService.setRequest((HttpServletRequest) (VaadinService.getCurrentRequest()));
    try {
        return publishService.getPublishData(cms, new HashMap<String, String>()/*params*/, null/*workflowId*/,
                null/*projectParam*/, pathList, null/*closelink*/, false/*confirmation*/);
    } catch (Exception e) {
        LOG.error(e.getLocalizedMessage(), e);
        return null;
    }
}

From source file:org.opencms.ui.dialogs.CmsNewDialog.java

License:Open Source License

/**
 * Creates a new instance.<p>// www . j  a  v a2  s .  c o  m
 *
 * @param folderResource the folder resource
 * @param context the context
 */
public CmsNewDialog(CmsResource folderResource, I_CmsDialogContext context) {
    m_folderResource = folderResource;
    m_dialogContext = context;

    Design.read(this);
    CmsVaadinUtils.visitDescendants(this, new Predicate<Component>() {

        public boolean apply(Component component) {

            component.setCaption(CmsVaadinUtils.localizeString(component.getCaption()));
            return true;
        }
    });
    CmsUUID initViewId = (CmsUUID) VaadinService.getCurrentRequest().getWrappedSession()
            .getAttribute(SETTING_STANDARD_VIEW);
    if (initViewId == null) {
        try {
            CmsUserSettings settings = new CmsUserSettings(A_CmsUI.getCmsObject());
            String viewSettingStr = settings
                    .getAdditionalPreference(CmsElementViewPreference.EXPLORER_PREFERENCE_NAME, true);
            if ((viewSettingStr != null) && CmsUUID.isValidUUID(viewSettingStr)) {
                initViewId = new CmsUUID(viewSettingStr);
            }
        } catch (Exception e) {
            LOG.error(e.getLocalizedMessage(), e);
        }
    }
    if (initViewId == null) {
        initViewId = CmsUUID.getNullUUID();
    }
    CmsElementView initView = initViews(initViewId);

    m_cancelButton.addClickListener(new ClickListener() {

        private static final long serialVersionUID = 1L;

        public void buttonClick(ClickEvent event) {

            finish(new ArrayList<CmsUUID>());
        }
    });

    m_defaultLocationCheckbox.setValue(getInitialValueForUseDefaultLocationOption(folderResource));
    m_defaultLocationCheckbox.addValueChangeListener(new ValueChangeListener() {

        private static final long serialVersionUID = 1L;

        public void valueChange(ValueChangeEvent event) {

            try {
                init(m_currentView, ((Boolean) event.getProperty().getValue()).booleanValue());
            } catch (Exception e) {
                m_dialogContext.error(e);
            }

        }
    });
    m_viewSelector.setNullSelectionAllowed(false);
    m_viewSelector.setTextInputAllowed(false);
    m_typeContainer.addLayoutClickListener(new LayoutClickListener() {

        private static final long serialVersionUID = 1L;

        public void layoutClick(LayoutClickEvent event) {

            CmsResourceTypeBean clickedType = (CmsResourceTypeBean) (((AbstractComponent) (event
                    .getChildComponent())).getData());
            handleSelection(clickedType);
        }
    });
    setActionHandler(new CmsOkCancelActionHandler() {

        private static final long serialVersionUID = 1L;

        @Override
        protected void cancel() {

            finish(new ArrayList<CmsUUID>());
        }

        @Override
        protected void ok() {

            // nothing to do
        }
    });
    init(initView, true);
}