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);
}
}
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;
}
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");
}
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));
}
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());
}
}
Aggregations