Search in sources :

Example 86 with Group

use of org.wso2.charon3.core.objects.Group in project charon by wso2.

the class GroupResource method updateGroup.

@PUT
@Path("{id}")
@Produces({ "application/json", "application/scim+json" })
@Consumes("application/scim+json")
@ApiOperation(value = "Return the updated group", notes = "Returns HTTP 404 if the group is not found.")
@ApiResponses(value = { @ApiResponse(code = 200, message = "Group is updated"), @ApiResponse(code = 404, message = "Valid group is not found") })
public Response updateGroup(@ApiParam(value = SCIMProviderConstants.ID_DESC, required = true) @PathParam(SCIMProviderConstants.ID) String id, @ApiParam(value = SCIMProviderConstants.ATTRIBUTES_DESC, required = false) @QueryParam(SCIMProviderConstants.ATTRIBUTES) String attribute, @ApiParam(value = SCIMProviderConstants.EXCLUDED_ATTRIBUTES_DESC, required = false) @QueryParam(SCIMProviderConstants.EXCLUDE_ATTRIBUTES) String excludedAttributes, String resourceString) throws FormatNotSupportedException, CharonException {
    try {
        // obtain the user store manager
        UserManager userManager = DefaultCharonManager.getInstance().getUserManager();
        // create charon-SCIM group endpoint and hand-over the request.
        GroupResourceManager groupResourceManager = new GroupResourceManager();
        SCIMResponse response = groupResourceManager.updateWithPUT(id, resourceString, userManager, attribute, excludedAttributes);
        return buildResponse(response);
    } catch (CharonException e) {
        throw new CharonException(e.getDetail(), e);
    }
}
Also used : UserManager(org.wso2.charon3.core.extensions.UserManager) GroupResourceManager(org.wso2.charon3.core.protocol.endpoints.GroupResourceManager) CharonException(org.wso2.charon3.core.exceptions.CharonException) SCIMResponse(org.wso2.charon3.core.protocol.SCIMResponse) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) Consumes(javax.ws.rs.Consumes) ApiOperation(io.swagger.annotations.ApiOperation) PUT(javax.ws.rs.PUT) ApiResponses(io.swagger.annotations.ApiResponses)

Example 87 with Group

use of org.wso2.charon3.core.objects.Group in project carbon-business-process by wso2.

the class ProcessImpl method getLinkArrows.

/**
 * Gets the Link arrow coordinates when there is a FLOW activity in the process
 *
 * @param doc SVG document which defines the components including shapes, gradients etc. of the process
 * @return An element which contains the link arrow coordinates of the Process
 */
private Element getLinkArrows(SVGDocument doc) {
    Element group = doc.createElementNS(SVGNamespace.SVG_NAMESPACE, "g");
    // Checks whether the any links exist
    if (links != null && !links.isEmpty()) {
        // Returns a collection-view of the map with the link names, sources(starting activity) and the target
        // (ending activity)
        Set linksSet = links.entrySet();
        Iterator linksIterator = linksSet.iterator();
        // Iterates through the links
        while (linksIterator.hasNext()) {
            Map.Entry<String, Link> link = (Map.Entry<String, Link>) linksIterator.next();
            // Gets the source/start activity of the link
            ActivityInterface startActivity = link.getValue().getSource();
            // Gets the target/end activity of the link
            ActivityInterface endActivity = link.getValue().getTarget();
            // Get the link name
            String linkName = link.getKey();
            // Check if the source and the target of the link contains a value
            if (endActivity != null && startActivity != null) {
                // Define the link flow/path by giving the coordinates of the start and end activity
                group.appendChild(drawLink(doc, startActivity.getExitArrowCoords().getXLeft(), startActivity.getExitArrowCoords().getYTop(), endActivity.getEntryArrowCoords().getXLeft(), endActivity.getEntryArrowCoords().getYTop(), startActivity.getStartIconWidth(), link.getKey(), linkName));
            }
        }
    }
    return group;
}
Also used : Set(java.util.Set) ActivityInterface(org.wso2.carbon.bpel.ui.bpel2svg.ActivityInterface) OMElement(org.apache.axiom.om.OMElement) Element(org.w3c.dom.Element) Iterator(java.util.Iterator) Map(java.util.Map) Link(org.wso2.carbon.bpel.ui.bpel2svg.Link)

Example 88 with Group

use of org.wso2.charon3.core.objects.Group in project carbon-business-process by wso2.

the class BPMNOSGIService method getGroupIdentityManager.

public static BPSGroupIdentityManager getGroupIdentityManager() {
    ProcessEngineImpl processEngine = (ProcessEngineImpl) getBPMNEngineService().getProcessEngine();
    ProcessEngineConfigurationImpl processEngineConfigurationImpl = null;
    if (processEngine != null) {
        processEngineConfigurationImpl = processEngine.getProcessEngineConfiguration();
        if (processEngineConfigurationImpl != null) {
            BPSGroupIdentityManager bpsGroupIdentityManager = null;
            if (processEngineConfigurationImpl.getSessionFactories() != null) {
                BPSGroupManagerFactory bpsGroupManagerFactory = (BPSGroupManagerFactory) processEngineConfigurationImpl.getSessionFactories().get(GroupIdentityManager.class);
                return (BPSGroupIdentityManager) bpsGroupManagerFactory.openSession();
            }
        }
    }
    throw new BPMNOSGIServiceException("Business Process Server Group manager couldn't be identified");
}
Also used : BPSGroupManagerFactory(org.wso2.carbon.bpmn.core.integration.BPSGroupManagerFactory) BPMNOSGIServiceException(org.wso2.carbon.bpmn.rest.common.exception.BPMNOSGIServiceException) GroupIdentityManager(org.activiti.engine.impl.persistence.entity.GroupIdentityManager) BPSGroupIdentityManager(org.wso2.carbon.bpmn.core.integration.BPSGroupIdentityManager) BPSGroupIdentityManager(org.wso2.carbon.bpmn.core.integration.BPSGroupIdentityManager) ProcessEngineConfigurationImpl(org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl) ProcessEngineImpl(org.activiti.engine.impl.ProcessEngineImpl)

Example 89 with Group

use of org.wso2.charon3.core.objects.Group in project product-iots by wso2.

the class DeviceGroupTest method isGroupCreatedTest.

@Test(description = "Check whether the created group exists", dependsOnMethods = { "addNewGroupTest" })
public void isGroupCreatedTest() throws IOException, XPathExpressionException {
    driver.get(getWebAppURL() + Constants.IOT_HOME_URL);
    DeviceGroupsPage groupsPage = adminDashboard.viewGroups();
    Assert.assertTrue(groupsPage.isGroupCreated(Constants.GROUP_NAME));
}
Also used : DeviceGroupsPage(org.wso2.iot.integration.ui.pages.groups.DeviceGroupsPage) Test(org.testng.annotations.Test)

Example 90 with Group

use of org.wso2.charon3.core.objects.Group in project carbon-apimgt by wso2.

the class APIPublisherImplTestCase method testUpdateAPIException.

@Test(description = "Exception when updating API")
public void testUpdateAPIException() throws APIManagementException {
    ApiDAO apiDAO = Mockito.mock(ApiDAO.class);
    APILifecycleManager apiLifecycleManager = Mockito.mock(APILifecycleManager.class);
    GatewaySourceGenerator gatewaySourceGenerator = Mockito.mock(GatewaySourceGenerator.class);
    APIGateway gateway = Mockito.mock(APIGateway.class);
    IdentityProvider identityProvider = Mockito.mock(IdentityProvider.class);
    PolicyDAO policyDAO = Mockito.mock(PolicyDAO.class);
    Policy apiPolicy = new APIPolicy(APIMgtConstants.DEFAULT_API_POLICY);
    apiPolicy.setUuid(UUID.randomUUID().toString());
    Mockito.when(policyDAO.getSimplifiedPolicyByLevelAndName(APIMgtAdminService.PolicyLevel.api, APIMgtConstants.DEFAULT_API_POLICY)).thenReturn(apiPolicy);
    Mockito.when(policyDAO.getSimplifiedPolicyByLevelAndName(APIMgtAdminService.PolicyLevel.subscription, GOLD_TIER)).thenReturn(new SubscriptionPolicy(GOLD_TIER));
    Mockito.when(policyDAO.getSimplifiedPolicyByLevelAndName(APIMgtAdminService.PolicyLevel.subscription, SILVER_TIER)).thenReturn(new SubscriptionPolicy(SILVER_TIER));
    Mockito.when(policyDAO.getSimplifiedPolicyByLevelAndName(APIMgtAdminService.PolicyLevel.subscription, BRONZE_TIER)).thenReturn(new SubscriptionPolicy(BRONZE_TIER));
    APIPublisherImpl apiPublisher = getApiPublisherImpl(identityProvider, apiDAO, apiLifecycleManager, gatewaySourceGenerator, gateway, policyDAO);
    API.APIBuilder api = SampleTestObjectCreator.createDefaultAPI();
    String uuid = api.getId();
    Mockito.when(apiDAO.getAPI(uuid)).thenReturn(api.build());
    Mockito.when(identityProvider.getRoleId(ADMIN_ROLE)).thenReturn(ADMIN_ROLE_ID);
    Mockito.when(identityProvider.getRoleId(DEVELOPER_ROLE)).thenReturn(DEVELOPER_ROLE_ID);
    // APIMgtDAOException
    Mockito.doThrow(new APIMgtDAOException("Error occurred while updating the API - " + api.getName())).when(apiDAO).updateAPI(uuid, api.build());
    Mockito.when(apiDAO.getApiSwaggerDefinition(api.getId())).thenReturn(SampleTestObjectCreator.apiDefinition);
    try {
        apiPublisher.updateAPI(api);
    } catch (APIManagementException e) {
        Assert.assertEquals(e.getMessage(), "Error occurred while updating the API - " + api.getName());
    }
    // ParseException
    try {
        apiPublisher.updateAPI(api.apiPermission("data{{]"));
    } catch (APIManagementException e) {
        Assert.assertEquals(e.getMessage(), "Error occurred while parsing the permission json from swagger - " + api.getName());
    }
    // GatewayException
    Mockito.doThrow(GatewayException.class).when(gateway).updateAPI(api.apiPermission("").build());
    try {
        apiPublisher.updateAPI(api.apiPermission(""));
    } catch (APIManagementException e) {
        Assert.assertEquals(e.getMessage(), "Error occurred while updating API - " + api.getName() + " in gateway");
    }
    // Error path
    // When Parse Exception is thrown during getAPIByUUID - replacing group ids with names
    Mockito.when(apiDAO.getAPI(uuid)).thenReturn(api.apiPermission("data{{]").build());
    try {
        apiPublisher.updateAPI(api.apiPermission("data{{]"));
    } catch (APIManagementException e) {
        Assert.assertEquals(e.getMessage(), "Error occurred while parsing the permission json string for API " + api.getName());
    }
}
Also used : SubscriptionPolicy(org.wso2.carbon.apimgt.core.models.policy.SubscriptionPolicy) Policy(org.wso2.carbon.apimgt.core.models.policy.Policy) APIPolicy(org.wso2.carbon.apimgt.core.models.policy.APIPolicy) APIMgtDAOException(org.wso2.carbon.apimgt.core.exception.APIMgtDAOException) APIBuilder(org.wso2.carbon.apimgt.core.models.API.APIBuilder) IdentityProvider(org.wso2.carbon.apimgt.core.api.IdentityProvider) GatewaySourceGenerator(org.wso2.carbon.apimgt.core.api.GatewaySourceGenerator) APILifecycleManager(org.wso2.carbon.apimgt.core.api.APILifecycleManager) APIManagementException(org.wso2.carbon.apimgt.core.exception.APIManagementException) SubscriptionPolicy(org.wso2.carbon.apimgt.core.models.policy.SubscriptionPolicy) API(org.wso2.carbon.apimgt.core.models.API) APIGateway(org.wso2.carbon.apimgt.core.api.APIGateway) APIPolicy(org.wso2.carbon.apimgt.core.models.policy.APIPolicy) ApiDAO(org.wso2.carbon.apimgt.core.dao.ApiDAO) PolicyDAO(org.wso2.carbon.apimgt.core.dao.PolicyDAO) Test(org.testng.annotations.Test)

Aggregations

Test (org.testng.annotations.Test)128 SiddhiManager (org.wso2.siddhi.core.SiddhiManager)97 SiddhiAppRuntime (org.wso2.siddhi.core.SiddhiAppRuntime)94 Event (org.wso2.siddhi.core.event.Event)87 InputHandler (org.wso2.siddhi.core.stream.input.InputHandler)78 QueryCallback (org.wso2.siddhi.core.query.output.callback.QueryCallback)51 Query (org.wso2.siddhi.query.api.execution.query.Query)17 ArrayList (java.util.ArrayList)16 CharonException (org.wso2.charon3.core.exceptions.CharonException)15 SCIMResponse (org.wso2.charon3.core.protocol.SCIMResponse)13 StreamCallback (org.wso2.siddhi.core.stream.output.StreamCallback)12 HashMap (java.util.HashMap)8 BadRequestException (org.wso2.charon3.core.exceptions.BadRequestException)8 SCIMResourceTypeSchema (org.wso2.charon3.core.schema.SCIMResourceTypeSchema)8 InternalErrorException (org.wso2.charon3.core.exceptions.InternalErrorException)7 UserManager (org.wso2.charon3.core.extensions.UserManager)7 Group (org.wso2.charon3.core.objects.Group)7 ApiOperation (io.swagger.annotations.ApiOperation)6 ApiResponses (io.swagger.annotations.ApiResponses)6 Produces (javax.ws.rs.Produces)6