Search in sources :

Example 16 with PropsFileActionReporter

use of com.sun.enterprise.v3.common.PropsFileActionReporter in project Payara by payara.

the class GetCommand method preAuthorizationForNonMonitoring.

private boolean preAuthorizationForNonMonitoring(final AdminCommandContext context) {
    report = context.getActionReport();
    /* Issue 5918 Used in ManifestManager to keep output sorted */
    try {
        PropsFileActionReporter reporter = (PropsFileActionReporter) report;
        reporter.useMainChildrenAttribute(true);
    } catch (ClassCastException e) {
    // ignore this is not a manifest output.
    }
    matchingNodesSorted = findSortedMatchingNodes();
    return matchingNodesSorted != null;
}
Also used : PropsFileActionReporter(com.sun.enterprise.v3.common.PropsFileActionReporter)

Example 17 with PropsFileActionReporter

use of com.sun.enterprise.v3.common.PropsFileActionReporter in project Payara by payara.

the class ListCommand method execute.

public void execute(AdminCommandContext context) {
    ActionReport report = context.getActionReport();
    /* Issue 5918 Used in ManifestManager to keep output sorted */
    try {
        PropsFileActionReporter reporter = (PropsFileActionReporter) report;
        reporter.useMainChildrenAttribute(true);
    } catch (ClassCastException e) {
    // ignore, this is not a manifest output
    }
    if (monitor) {
        listMonitorElements(context);
        return;
    }
    List<Map.Entry> matchingNodesSorted = sortNodesByDottedName(matchingNodes);
    for (Map.Entry<Dom, String> node : matchingNodesSorted) {
        ActionReport.MessagePart part = report.getTopMessagePart().addChild();
        part.setChildrenType("DottedName");
        if (parentNodes[0].name.isEmpty()) {
            part.setMessage(node.getValue());
        } else {
            part.setMessage(parentNodes[0].name + "." + node.getValue());
        }
    }
}
Also used : Dom(org.jvnet.hk2.config.Dom) ActionReport(org.glassfish.api.ActionReport) PropsFileActionReporter(com.sun.enterprise.v3.common.PropsFileActionReporter) HashMap(java.util.HashMap) Map(java.util.Map)

Example 18 with PropsFileActionReporter

use of com.sun.enterprise.v3.common.PropsFileActionReporter in project Payara by payara.

the class DeleteJdbcResourceTest method setUp.

@Before
public void setUp() {
    assertTrue(resources != null);
    // Create a JDBC Resource jdbc/foo for each test
    CreateJdbcResource createCommand = habitat.getService(CreateJdbcResource.class);
    assertTrue(createCommand != null);
    parameters.add("connectionpoolid", "DerbyPool");
    parameters.add("DEFAULT", "jdbc/foo");
    context = new AdminCommandContextImpl(LogDomains.getLogger(DeleteJdbcResourceTest.class, LogDomains.ADMIN_LOGGER), new PropsFileActionReporter());
    cr.getCommandInvocation("create-jdbc-resource", context.getActionReport(), adminSubject()).parameters(parameters).execute(createCommand);
    assertEquals(ActionReport.ExitCode.SUCCESS, context.getActionReport().getActionExitCode());
    // Setup for delete-jdbc-resource
    parameters = new ParameterMap();
    deleteCommand = habitat.getService(DeleteJdbcResource.class);
    assertTrue(deleteCommand != null);
}
Also used : AdminCommandContextImpl(org.glassfish.api.admin.AdminCommandContextImpl) ParameterMap(org.glassfish.api.admin.ParameterMap) PropsFileActionReporter(com.sun.enterprise.v3.common.PropsFileActionReporter) Before(org.junit.Before)

Example 19 with PropsFileActionReporter

use of com.sun.enterprise.v3.common.PropsFileActionReporter in project Payara by payara.

the class CreateJdbcResourceTest method setUp.

@Before
public void setUp() {
    assertTrue(resources != null);
    // Get an instance of the CreateJdbcResource command
    command = habitat.getService(CreateJdbcResource.class);
    assertTrue(command != null);
    // Set the options and operand to pass to the command
    parameters.set("connectionpoolid", "DerbyPool");
    parameters.set("enabled", "true");
    parameters.set("description", "my resource");
    parameters.set("DEFAULT", "jdbc/foo");
    context = new AdminCommandContextImpl(LogDomains.getLogger(CreateJdbcResourceTest.class, LogDomains.ADMIN_LOGGER), new PropsFileActionReporter());
    cr = habitat.getService(CommandRunner.class);
}
Also used : AdminCommandContextImpl(org.glassfish.api.admin.AdminCommandContextImpl) PropsFileActionReporter(com.sun.enterprise.v3.common.PropsFileActionReporter) CommandRunner(org.glassfish.api.admin.CommandRunner) Before(org.junit.Before)

Example 20 with PropsFileActionReporter

use of com.sun.enterprise.v3.common.PropsFileActionReporter in project Payara by payara.

the class ListJdbcResourcesTest method testExecuteFailInvalidOption.

/**
 * Test of execute method, of class ListJdbcResource.
 * list-jdbc-resources --invalid invalid
 */
@Ignore
@Test
public void testExecuteFailInvalidOption() {
    listCommand = habitat.getService(ListJdbcResources.class);
    parameters.add("invalid", "invalid");
    context = new AdminCommandContextImpl(LogDomains.getLogger(ListJdbcResourcesTest.class, LogDomains.ADMIN_LOGGER), new PropsFileActionReporter());
    cr.getCommandInvocation("list-jdbc-resources", context.getActionReport(), adminSubject()).parameters(parameters).execute(listCommand);
    List<MessagePart> list = context.getActionReport().getTopMessagePart().getChildren();
    assertEquals(1, list.size());
    for (MessagePart mp : list) {
        assertEquals("Usage: list-jdbc-resources ", mp.getMessage());
    }
    // Check the exit code is FAILURE
    assertEquals(ActionReport.ExitCode.FAILURE, context.getActionReport().getActionExitCode());
}
Also used : AdminCommandContextImpl(org.glassfish.api.admin.AdminCommandContextImpl) MessagePart(org.glassfish.api.ActionReport.MessagePart) PropsFileActionReporter(com.sun.enterprise.v3.common.PropsFileActionReporter) Ignore(org.junit.Ignore) Test(org.junit.Test) ConfigApiTest(org.glassfish.tests.utils.ConfigApiTest)

Aggregations

PropsFileActionReporter (com.sun.enterprise.v3.common.PropsFileActionReporter)30 AdminCommandContextImpl (org.glassfish.api.admin.AdminCommandContextImpl)23 ParameterMap (org.glassfish.api.admin.ParameterMap)19 Before (org.junit.Before)14 CommandRunner (org.glassfish.api.admin.CommandRunner)13 ConfigApiTest (org.glassfish.tests.utils.ConfigApiTest)9 Test (org.junit.Test)9 MessagePart (org.glassfish.api.ActionReport.MessagePart)7 ActionReport (org.glassfish.api.ActionReport)5 Domain (com.sun.enterprise.config.serverbeans.Domain)4 Resource (com.sun.enterprise.config.serverbeans.Resource)4 Resources (com.sun.enterprise.config.serverbeans.Resources)3 IiopService (org.glassfish.orb.admin.config.IiopService)3 RestPayloadImpl (com.sun.enterprise.admin.remote.RestPayloadImpl)2 CachedCommandModel (com.sun.enterprise.admin.util.CachedCommandModel)2 ArrayList (java.util.ArrayList)2 ResponseBuilder (javax.ws.rs.core.Response.ResponseBuilder)2 Ignore (org.junit.Ignore)2 ParamsWithPayload (com.sun.enterprise.admin.remote.ParamsWithPayload)1 ActionReporter (com.sun.enterprise.v3.common.ActionReporter)1