Package org.jboss.as.console.client.core

Examples of org.jboss.as.console.client.core.BootstrapContext


    }

    @Override
    public void execute(final Control<BootstrapContext> control) {

        final BootstrapContext context = control.getContext();

        final ModelNode operation = new ModelNode();
        operation.get(OP).set(COMPOSITE);
        operation.get(ADDRESS).setEmptyList();

        ModelNode step;
        List<ModelNode> steps = new ArrayList<ModelNode>();

        // exec type
        step = new ModelNode();
        step.get(OP).set(READ_ATTRIBUTE_OPERATION);
        step.get(NAME).set("process-type");
        step.get(ADDRESS).setEmptyList();
        steps.add(step);

        // product name
        step = new ModelNode();
        step.get(OP).set(READ_ATTRIBUTE_OPERATION);
        step.get(NAME).set("product-name");
        step.get(ADDRESS).setEmptyList();
        steps.add(step);

        // release codename
        step = new ModelNode();
        step.get(OP).set(READ_ATTRIBUTE_OPERATION);
        step.get(NAME).set("release-codename");
        step.get(ADDRESS).setEmptyList();
        steps.add(step);

        // product version
        step = new ModelNode();
        step.get(OP).set(READ_ATTRIBUTE_OPERATION);
        step.get(NAME).set("product-version");
        step.get(ADDRESS).setEmptyList();
        steps.add(step);

        // release version
        step = new ModelNode();
        step.get(OP).set(READ_ATTRIBUTE_OPERATION);
        step.get(NAME).set("release-version");
        step.get(ADDRESS).setEmptyList();
        steps.add(step);

        // whoami
        step = new ModelNode();
        step.get(OP).set("whoami");
        step.get(ADDRESS).setEmptyList();
        step.get("verbose").set(true);
        steps.add(step);

        operation.get(STEPS).set(steps);

        dispatcher.execute(new DMRAction(operation), new AsyncCallback<DMRResponse>() {

            @Override
            public void onFailure(Throwable caught) {
                context.setlastError(caught);
                Log.error(caught.getMessage());
                control.abort();
            }

            @Override
            public void onSuccess(DMRResponse result) {
                ModelNode response = result.get();

                if(response.isFailure()) {
                    context.setlastError(new RuntimeException(response.getFailureDescription()));
                    control.abort();
                } else {
                    // capture exec mode
                    ModelNode execMode = response.get(RESULT).get("step-1");
                    boolean isServer = execMode.get(RESULT).asString().equals("Server");
                    context.setProperty(BootstrapContext.STANDALONE, Boolean.valueOf(isServer).toString());

                    // product name, release codename
                    ModelNode productName = response.get(RESULT).get("step-2");
                    ModelNode releaseCodename = response.get(RESULT).get("step-3");
                    if (productName.get(RESULT).isDefined()) {
                        context.setProductName(productName.get(RESULT).asString());
                    } else if (releaseCodename.get(RESULT).isDefined()) {
                        context.setProductName(releaseCodename.get(RESULT).asString());
                    }

                    // product version, release version
                    ModelNode productVersion = response.get(RESULT).get("step-4");
                    ModelNode releaseVersion = response.get(RESULT).get("step-5");
                    if (productVersion.get(RESULT).isDefined()) {
                        context.setProductVersion(productVersion.get(RESULT).asString());
                    } else if (releaseVersion.get(RESULT).isDefined()) {
                        context.setProductVersion(releaseVersion.get(RESULT).asString());
                    }

                    ModelNode whoami = response.get(RESULT).get("step-6");
                    ModelNode whoamiResult = whoami.get(RESULT);

                    String username = whoamiResult.get("identity").get("username").asString();
                    context.setPrincipal(username);
                    Set<String> mappedRoles = new HashSet<String>();
                    if(whoamiResult.hasDefined("mapped-roles"))
                    {
                        List<ModelNode> roles = whoamiResult.get("mapped-roles").asList();
                        for(ModelNode role : roles)
                        {
                            final String roleName = role.asString();
                            mappedRoles.add(roleName);
                        }
                    }
                    context.setRoles(mappedRoles);

                    if(context.isSuperUser() && Preferences.has(Preferences.Key.RUN_AS_ROLE))
                    {
                        String runAsRole = Preferences.get(Preferences.Key.RUN_AS_ROLE);
                        dispatcher.setProperty("run_as", runAsRole);
                        context.setRunAs(runAsRole);
                    }
                    Preferences.clear(Preferences.Key.RUN_AS_ROLE);

                    control.proceed();
                }
View Full Code Here


    }

    @Override
    public void execute(final Control<BootstrapContext> control) {

        final BootstrapContext context = control.getContext();

        final ModelNode operation = new ModelNode();
        operation.get(OP).set(COMPOSITE);
        operation.get(ADDRESS).setEmptyList();

        ModelNode step;
        List<ModelNode> steps = new ArrayList<ModelNode>();

        // exec type
        step = new ModelNode();
        step.get(OP).set(READ_ATTRIBUTE_OPERATION);
        step.get(NAME).set("process-type");
        step.get(ADDRESS).setEmptyList();
        steps.add(step);

        // product name
        step = new ModelNode();
        step.get(OP).set(READ_ATTRIBUTE_OPERATION);
        step.get(NAME).set("product-name");
        step.get(ADDRESS).setEmptyList();
        steps.add(step);

        // release codename
        step = new ModelNode();
        step.get(OP).set(READ_ATTRIBUTE_OPERATION);
        step.get(NAME).set("release-codename");
        step.get(ADDRESS).setEmptyList();
        steps.add(step);

        // product version
        step = new ModelNode();
        step.get(OP).set(READ_ATTRIBUTE_OPERATION);
        step.get(NAME).set("product-version");
        step.get(ADDRESS).setEmptyList();
        steps.add(step);

        // release version
        step = new ModelNode();
        step.get(OP).set(READ_ATTRIBUTE_OPERATION);
        step.get(NAME).set("release-version");
        step.get(ADDRESS).setEmptyList();
        steps.add(step);

        // whoami
        step = new ModelNode();
        step.get(OP).set("whoami");
        step.get(ADDRESS).setEmptyList();
        step.get("verbose").set(true);
        steps.add(step);

        operation.get(STEPS).set(steps);

        dispatcher.execute(new DMRAction(operation), new AsyncCallback<DMRResponse>() {

            @Override
            public void onFailure(Throwable caught) {
                context.setlastError(caught);
                Log.error(caught.getMessage());
                control.abort();
            }

            @Override
            public void onSuccess(DMRResponse result) {
                ModelNode response = result.get();

                if(response.isFailure()) {
                    context.setlastError(new RuntimeException(response.getFailureDescription()));
                    control.abort();
                } else {
                    // capture exec mode
                    ModelNode execMode = response.get(RESULT).get("step-1");
                    boolean isServer = execMode.get(RESULT).asString().equals("Server");
                    context.setProperty(BootstrapContext.STANDALONE, Boolean.valueOf(isServer).toString());

                    // product name, release codename
                    ModelNode productName = response.get(RESULT).get("step-2");
                    ModelNode releaseCodename = response.get(RESULT).get("step-3");
                    if (productName.get(RESULT).isDefined()) {
                        context.setProductName(productName.get(RESULT).asString());
                    } else if (releaseCodename.get(RESULT).isDefined()) {
                        context.setProductName(releaseCodename.get(RESULT).asString());
                    }

                    // product version, release version
                    ModelNode productVersion = response.get(RESULT).get("step-4");
                    ModelNode releaseVersion = response.get(RESULT).get("step-5");
                    if (productVersion.get(RESULT).isDefined()) {
                        context.setProductVersion(productVersion.get(RESULT).asString());
                    } else if (releaseVersion.get(RESULT).isDefined()) {
                        context.setProductVersion(releaseVersion.get(RESULT).asString());
                    }

                    ModelNode whoami = response.get(RESULT).get("step-6");
                    ModelNode whoamiResult = whoami.get(RESULT);
                    System.out.println(whoamiResult);

                    String username = whoamiResult.get("identity").get("username").asString();
                    context.setPrincipal(username);
                    Set<String> mappedRoles = new HashSet<String>();
                    if(whoamiResult.hasDefined("mapped-roles"))
                    {
                        List<ModelNode> roles = whoamiResult.get("mapped-roles").asList();
                        for(ModelNode role : roles)
                        {
                            final String roleName = role.asString();
                            mappedRoles.add(roleName);
                        }
                    }
                    context.setRoles(mappedRoles);

                    if(context.isSuperUser() && Preferences.has(Preferences.Key.RUN_AS_ROLE))
                    {
                        String runAsRole = Preferences.get(Preferences.Key.RUN_AS_ROLE);
                        dispatcher.setProperty("run_as", runAsRole);
                        context.setRunAs(runAsRole);
                    }
                    Preferences.clear(Preferences.Key.RUN_AS_ROLE);

                    control.proceed();
                }
View Full Code Here

public class ChoseProcessor implements Function<BootstrapContext> {

    @Override
    public void execute(Control<BootstrapContext> control) {

        BootstrapContext bootstrap = control.getContext();
        ResponseProcessorFactory.INSTANCE.bootstrap(bootstrap.isStandalone());
        control.proceed();
    }
View Full Code Here

        releaseVersion.get(ADDRESS).setEmptyList();
        steps.add(releaseVersion);
       
        operation.get(STEPS).set(steps);

        final BootstrapContext bootstrap = control.getContext();

        dispatcher.execute(new DMRAction(operation), new AsyncCallback<DMRResponse>() {
            @Override
            public void onFailure(Throwable caught) {

                bootstrap.setlastError(caught);
                Log.error(caught.getMessage());

                control.abort();
            }

            @Override
            public void onSuccess(DMRResponse result) {

                ModelNode response = result.get();

                if(response.isFailure())
                {
                    bootstrap.setlastError(new RuntimeException(response.getFailureDescription()));
                    control.abort();
                }
                else
                {

                    // capture exec mode
                    ModelNode execResult = response.get(RESULT).get("step-1");
                    boolean isServer = execResult.get(RESULT).asString().equals("Server");
                    bootstrap.setProperty(BootstrapContext.STANDALONE, Boolean.valueOf(isServer).toString());

                    ModelNode prodVersionResult = response.get(RESULT).get("step-2");
                    String prodVersion = prodVersionResult.get(RESULT).isDefined() ?
                            prodVersionResult.get(RESULT).asString() : "";

                    ModelNode releaseResult = response.get(RESULT).get("step-3");
                    String releaseVersion = releaseResult.get(RESULT).isDefined() ?
                            releaseResult.get(RESULT).asString() : "";

                    bootstrap.setReleaseVersion(releaseVersion);
                    bootstrap.setProdVersion(prodVersion);

                    control.proceed();
                }

View Full Code Here

        this.groupStore = groupStore;
    }

    @Override
    public void execute(final Control<BootstrapContext> control) {
        final BootstrapContext context = control.getContext();

        if(!context.isStandalone())
        {
            groupStore.loadServerGroups(new AsyncCallback<List<ServerGroupRecord>>() {
                @Override
                public void onFailure(Throwable caught) {
                    context.setlastError(caught);
                    control.abort();
                }

                @Override
                public void onSuccess(List<ServerGroupRecord> result) {
                    if(result.isEmpty())
                    {
                        context.setGroupManagementDisabled(true);
                    }

                    Set<String> groups = new TreeSet<String>();
                    for(ServerGroupRecord group : result) groups.add(group.getName());
                    control.getContext().setAdressableGroups(groups);
View Full Code Here

public class EagerLoadProfiles implements AsyncCommand<Boolean> {

    @Override
    public void execute(final AsyncCallback<Boolean> callback) {

        BootstrapContext bootstrapContext = Console.MODULES.getBootstrapContext();

        if(!bootstrapContext.isStandalone())
        {
            ProfileStore profileStore = Console.MODULES.getProfileStore();

            profileStore.loadProfiles(new SimpleCallback<List<ProfileRecord>>() {
View Full Code Here

        this.groupStore = groupStore;
    }

    @Override
    public void execute(final Control<BootstrapContext> control) {
        final BootstrapContext context = control.getContext();

        if (!context.isStandalone()) {
            groupStore.loadServerGroups(new AsyncCallback<List<ServerGroupRecord>>() {
                @Override
                public void onFailure(Throwable caught) {
                    context.setlastError(caught);
                    control.abort();
                }

                @Override
                public void onSuccess(List<ServerGroupRecord> result) {
                    if (result.isEmpty()) {
                        final DefaultWindow window = new DefaultWindow(Console.MESSAGES.no_groups_header());
                        window.setWidth(480);
                        window.setHeight(220);
                        window.trapWidget(new NoGroupsWarning(new ClickHandler() {
                            @Override
                            public void onClick(final ClickEvent event) {
                                window.hide();
                                context.setGroupManagementDisabled(true);
                                control.proceed();
                            }
                        }).asWidget());
                        window.setGlassEnabled(true);
                        window.center();
                    } else {
                        Set<String> groups = new TreeSet<String>();
                        for (ServerGroupRecord group : result) { groups.add(group.getName()); }
                        context.setAdressableGroups(groups);
                        control.proceed();
                    }
                }
            });
        } else {
View Full Code Here

        this.domainManager = domainManager;
    }

    @Override
    public void execute(final Control<BootstrapContext> control) {
        final BootstrapContext context = control.getContext();

        if (!context.isStandalone()) {
            HostList initialHosts = context.getInitialHosts();
            if (!initialHosts.isEmpty()) {
                domainManager
                        .getServerInstances(initialHosts.getSelectedHost().getName(), new AsyncCallback<ServerInstanceList>() {
                            @Override
                            public void onFailure(final Throwable caught) {
                                control.proceed();
                            }

                            @Override
                            public void onSuccess(final ServerInstanceList result) {
                                context.setInitialServer(result.getSelectedServer());
                                control.proceed();
                            }
                        });
            } else {
                control.proceed();
View Full Code Here

        this.domainManager = domainManager;
    }

    @Override
    public void execute(final Control<BootstrapContext> control) {
        final BootstrapContext context = control.getContext();

        if(!context.isStandalone())
        {
            domainManager.getHosts(new SimpleCallback<HostList>() {

                @Override
                public void onFailure(Throwable caught) {
                    if(caught instanceof DomainEntityManager.NoHostsAvailable)
                    {
                        // this is expected (host scoped roles)
                        context.setHostManagementDisabled(true);
                        control.proceed();
                    }
                    else
                    {
                        context.setlastError(caught);
                        control.abort();
                    }
                }

                @Override
                public void onSuccess(HostList hostList) {
                    Log.info("Identified " + hostList.getHosts().size() + " hosts in this domain");
                    context.setInitialHosts(hostList);
                    if(hostList.isEmpty()) {
                        context.setHostManagementDisabled(true);
                    }

                    Set<String> hosts = new TreeSet<String>();
                    for(Host host : hostList.getHosts()) hosts.add(host.getName());
                    control.getContext().setAddressableHosts(hosts);
View Full Code Here

        this.groupStore = groupStore;
    }

    @Override
    public void execute(final Control<BootstrapContext> control) {
        final BootstrapContext context = control.getContext();

        if (!context.isStandalone()) {
            groupStore.loadServerGroups(new AsyncCallback<List<ServerGroupRecord>>() {
                @Override
                public void onFailure(Throwable caught) {
                    context.setlastError(caught);
                    control.abort();
                }

                @Override
                public void onSuccess(List<ServerGroupRecord> result) {
                    if (result.isEmpty()) {
                        final DefaultWindow window = new DefaultWindow(Console.MESSAGES.no_groups_header());
                        window.setWidth(480);
                        window.setHeight(220);
                        window.trapWidget(new NoGroupsWarning(new ClickHandler() {
                            @Override
                            public void onClick(final ClickEvent event) {
                                window.hide();
                                context.setGroupManagementDisabled(true);
                                control.proceed();
                            }
                        }).asWidget());
                        window.setGlassEnabled(true);
                        window.center();
                    } else {
                        Set<String> groups = new TreeSet<String>();
                        for (ServerGroupRecord group : result) { groups.add(group.getName()); }
                        context.setAdressableGroups(groups);
                        control.proceed();
                    }
                }
            });
        } else {
View Full Code Here

TOP

Related Classes of org.jboss.as.console.client.core.BootstrapContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.