Merge pull request #1267 from charithag/master

Fixed issue in deploying execution plans as non admin user
revert-70aa11f8
Geeth 6 years ago committed by GitHub
commit 5cec8ae8d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -51,6 +51,7 @@ import org.wso2.carbon.identity.jwt.client.extension.service.JWTClientManagerSer
import org.wso2.carbon.registry.api.Registry; import org.wso2.carbon.registry.api.Registry;
import org.wso2.carbon.registry.api.RegistryException; import org.wso2.carbon.registry.api.RegistryException;
import org.wso2.carbon.registry.api.Resource; import org.wso2.carbon.registry.api.Resource;
import org.wso2.carbon.stratos.common.util.ClaimsMgtUtil;
import javax.net.ssl.KeyManagerFactory; import javax.net.ssl.KeyManagerFactory;
import javax.net.ssl.SSLContext; import javax.net.ssl.SSLContext;
@ -428,6 +429,9 @@ public class GeoLocationProviderServiceImpl implements GeoLocationProviderServic
} catch (JWTClientException e) { } catch (JWTClientException e) {
throw new GeoLocationBasedServiceException( throw new GeoLocationBasedServiceException(
"JWT token creation failed while " + action + " geo alert '" + alertType, e); "JWT token creation failed while " + action + " geo alert '" + alertType, e);
} catch (Exception e) {
throw new GeoLocationBasedServiceException(
"Error occurred while " + action + " geo alert '" + alertType, e);
} finally { } finally {
cleanup(eventprocessorStub); cleanup(eventprocessorStub);
} }
@ -541,6 +545,9 @@ public class GeoLocationProviderServiceImpl implements GeoLocationProviderServic
throw new GeoLocationBasedServiceException( throw new GeoLocationBasedServiceException(
"JWT token creation failed while " + action + " geo alert '" + alertType + "' for " + "JWT token creation failed while " + action + " geo alert '" + alertType + "' for " +
identifier.getType() + " device with id:" + identifier.getId(), e); identifier.getType() + " device with id:" + identifier.getId(), e);
} catch (Exception e) {
throw new GeoLocationBasedServiceException(
"Error occurred while " + action + " geo alert '" + alertType, e);
} finally { } finally {
cleanup(eventprocessorStub); cleanup(eventprocessorStub);
} }
@ -646,6 +653,9 @@ public class GeoLocationProviderServiceImpl implements GeoLocationProviderServic
executionPlanName + " for " + executionPlanName + " for " +
identifier.getType() + " device with id:" + identifier.getId(), e identifier.getType() + " device with id:" + identifier.getId(), e
); );
} catch (Exception e) {
throw new GeoLocationBasedServiceException(
"Error occurred while removing geo alert '" + alertType, e);
} finally { } finally {
cleanup(eventprocessorStub); cleanup(eventprocessorStub);
} }
@ -672,6 +682,9 @@ public class GeoLocationProviderServiceImpl implements GeoLocationProviderServic
"JWT token creation failed while removing geo alert '" + alertType + "': " + "JWT token creation failed while removing geo alert '" + alertType + "': " +
executionPlanName, e executionPlanName, e
); );
} catch (Exception e) {
throw new GeoLocationBasedServiceException(
"Error occurred while removing geo alert '" + alertType, e);
} finally { } finally {
cleanup(eventprocessorStub); cleanup(eventprocessorStub);
} }
@ -702,14 +715,16 @@ public class GeoLocationProviderServiceImpl implements GeoLocationProviderServic
} }
} }
protected EventProcessorAdminServiceStub getEventProcessorAdminServiceStub() throws JWTClientException { protected EventProcessorAdminServiceStub getEventProcessorAdminServiceStub() throws Exception {
//send alert to event-processing //send alert to event-processing
String eventProcessorAdminServiceWSUrl = Utils.replaceSystemProperty(GeoServices.DAS_URL) + String eventProcessorAdminServiceWSUrl = Utils.replaceSystemProperty(GeoServices.DAS_URL) +
"/services/EventProcessorAdminService"; "/services/EventProcessorAdminService";
//Getting the tenant Domain //Getting the tenant Domain
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain();
String username = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); String username = ClaimsMgtUtil.getAdminUserNameFromTenantId(DeviceManagementDataHolder.getInstance().getRealmService(),
tenantId);
String tenantAdminUser = username + "@" + tenantDomain; String tenantAdminUser = username + "@" + tenantDomain;
try { try {

@ -143,7 +143,7 @@ public class GeoLocationProviderServiceTest {
Assert.assertEquals(geoFenceNode.getStationaryTime(), SAMPLE_STATIONARY_TIME); Assert.assertEquals(geoFenceNode.getStationaryTime(), SAMPLE_STATIONARY_TIME);
} }
private void initMocks() throws JWTClientException, RemoteException { private void initMocks() throws Exception {
EventProcessorAdminServiceStub mockEventProcessorAdminServiceStub = Mockito.mock(EventProcessorAdminServiceStub.class); EventProcessorAdminServiceStub mockEventProcessorAdminServiceStub = Mockito.mock(EventProcessorAdminServiceStub.class);
geoLocationProviderServiceImpl = Mockito.mock(GeoLocationProviderServiceImpl.class, Mockito.CALLS_REAL_METHODS); geoLocationProviderServiceImpl = Mockito.mock(GeoLocationProviderServiceImpl.class, Mockito.CALLS_REAL_METHODS);
mockExecutionPlanConfigurationDto[0] = Mockito.mock(ExecutionPlanConfigurationDto.class); mockExecutionPlanConfigurationDto[0] = Mockito.mock(ExecutionPlanConfigurationDto.class);

Loading…
Cancel
Save