本文整理汇总了Java中org.sunbird.common.exception.ProjectCommonException类的典型用法代码示例。如果您正苦于以下问题:Java ProjectCommonException类的具体用法?Java ProjectCommonException怎么用?Java ProjectCommonException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ProjectCommonException类属于org.sunbird.common.exception包,在下文中一共展示了ProjectCommonException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getRecordsByProperty
import org.sunbird.common.exception.ProjectCommonException; //导入依赖的package包/类
@Override
public Response getRecordsByProperty(String keyspaceName, String tableName, String propertyName,
List<Object> propertyValueList) {
long startTime = System.currentTimeMillis();
ProjectLogger.log("Cassandra Service getRecordsByProperty method started at ==" + startTime,
LoggerEnum.PERF_LOG);
Response response = new Response();
try {
Select selectQuery = QueryBuilder.select().all().from(keyspaceName, tableName);
Where selectWhere = selectQuery.where();
Clause clause = QueryBuilder.in(propertyName, propertyValueList);
selectWhere.and(clause);
ResultSet results = connectionManager.getSession(keyspaceName).execute(selectQuery);
response = CassandraUtil.createResponse(results);
} catch (Exception e) {
ProjectLogger.log(Constants.EXCEPTION_MSG_FETCH + tableName + " : " + e.getMessage(), e);
throw new ProjectCommonException(ResponseCode.SERVER_ERROR.getErrorCode(),
ResponseCode.SERVER_ERROR.getErrorMessage(), ResponseCode.SERVER_ERROR.getResponseCode());
}
long stopTime = System.currentTimeMillis();
long elapsedTime = stopTime - startTime;
ProjectLogger.log("Cassandra Service getRecordsByProperty method end at ==" + stopTime
+ " ,Total time elapsed = " + elapsedTime, LoggerEnum.PERF_LOG);
return response;
}
示例2: test19ApproveOrgExcInvalidOrgId
import org.sunbird.common.exception.ProjectCommonException; //导入依赖的package包/类
@Test
public void test19ApproveOrgExcInvalidOrgId(){
TestKit probe = new TestKit(system);
ActorRef subject = system.actorOf(props);
Request reqObj = new Request();
reqObj.setOperation(ActorOperations.APPROVE_ORG.getValue());
HashMap<String, Object> innerMap = new HashMap<>();
Map<String , Object> orgMap = new HashMap<String , Object>();
orgMap.put(JsonKey.ORGANISATION_ID , orgId+"6389");
innerMap.put(JsonKey.ORGANISATION , orgMap);
reqObj.setRequest(innerMap);
subject.tell(reqObj, probe.getRef());
probe.expectMsgClass(duration("200 second"),ProjectCommonException.class);
}
示例3: setEmailVerifiedTrue
import org.sunbird.common.exception.ProjectCommonException; //导入依赖的package包/类
@Override
public String setEmailVerifiedTrue(String userId) {
try {
UserResource resource =
keycloak.realm(KeyCloakConnectionProvider.SSO_REALM).users().get(userId);
UserRepresentation ur = resource.toRepresentation();
ur.setEmailVerified(true);
if (isNotNull(resource)) {
try {
resource.update(ur);
} catch (Exception ex) {
ProjectLogger.log(ex.getMessage(), ex);
throw new ProjectCommonException(ResponseCode.invalidUsrData.getErrorCode(),
ResponseCode.invalidUsrData.getErrorMessage(),
ResponseCode.CLIENT_ERROR.getResponseCode());
}
}
} catch (Exception e) {
ProjectLogger.log(e.getMessage(), e);
throw new ProjectCommonException(ResponseCode.invalidUsrData.getErrorCode(),
ResponseCode.invalidUsrData.getErrorMessage(),
ResponseCode.CLIENT_ERROR.getResponseCode());
}
return JsonKey.SUCCESS;
}
示例4: doUserBasicValidationFirstNameTest
import org.sunbird.common.exception.ProjectCommonException; //导入依赖的package包/类
@Test
public void doUserBasicValidationFirstNameTest() {
Request request = new Request();
Map<String, Object> requestObj = new HashMap<>();
requestObj.put(JsonKey.USERNAME, "test123");
requestObj.put(JsonKey.FIRST_NAME, "");
request.setRequest(requestObj);
try {
RequestValidator.doUserBasicValidation(request);
} catch (ProjectCommonException e) {
assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(),
e.getResponseCode());
assertEquals(ResponseCode.firstNameRequired.getErrorCode(),
e.getCode());
}
}
示例5: deleteGeoLocation
import org.sunbird.common.exception.ProjectCommonException; //导入依赖的package包/类
/**
* Delete geo location on basis of location id.
* @param actorMessage
*/
private void deleteGeoLocation(Request actorMessage) {
ProjectLogger.log("GeoLocationManagementActor-updateGeoLocation called");
String locationId = (String) actorMessage.getRequest().get(JsonKey.LOCATION_ID);
Response finalResponse = new Response();
if(ProjectUtil.isStringNullOREmpty(locationId)){
throw new ProjectCommonException(ResponseCode.invalidRequestData.getErrorCode(),
ResponseCode.invalidRequestData.getErrorMessage(),
ResponseCode.CLIENT_ERROR.getResponseCode());
}
cassandraOperation.deleteRecord(geoLocationDbInfo.getKeySpace(), geoLocationDbInfo.getTableName(), locationId);
finalResponse.getResult().put(JsonKey.RESPONSE , JsonKey.SUCCESS);
sender().tell(finalResponse , self());
}
示例6: testCourseProgressReportWithInvalidBatchIdNull
import org.sunbird.common.exception.ProjectCommonException; //导入依赖的package包/类
@Test
public void testCourseProgressReportWithInvalidBatchIdNull(){
TestKit probe = new TestKit(system);
ActorRef subject = system.actorOf(props);
Request actorMessage = new Request();
actorMessage.put(JsonKey.REQUESTED_BY , userId);
actorMessage.put(JsonKey.BATCH_ID , "");
actorMessage.put(JsonKey.PERIOD , "fromBegining");
actorMessage.put(JsonKey.FORMAT, "csv");
actorMessage.setOperation(ActorOperations.COURSE_PROGRESS_METRICS_REPORT.getValue());
subject.tell(actorMessage, probe.getRef());
ProjectCommonException res= probe.expectMsgClass(duration("100 second"),ProjectCommonException.class);
}
示例7: createUserAddressTypeTest
import org.sunbird.common.exception.ProjectCommonException; //导入依赖的package包/类
@Test
public void createUserAddressTypeTest() {
Request request = new Request();
Map<String, Object> requestObj = new HashMap<>();
requestObj.put(JsonKey.PHONE, "9321234123");
requestObj.put(JsonKey.EMAIL, "[email protected]");
requestObj.put(JsonKey.USERNAME, "test123");
requestObj.put(JsonKey.FIRST_NAME, "test123");
List<Map<String,Object>> addressList = new ArrayList<>();
Map<String,Object> map = new HashMap<>();
map.put(JsonKey.ADDRESS_LINE1, "test");
map.put(JsonKey.CITY, "Bangalore");
map.put(JsonKey.COUNTRY, "India");
map.put(JsonKey.ADD_TYPE, "localr");
addressList.add(map);
requestObj.put(JsonKey.ADDRESS, addressList);
request.setRequest(requestObj);
try {
RequestValidator.validateCreateUser(request);
} catch (ProjectCommonException e) {
assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(),
e.getResponseCode());
assertEquals(ResponseCode.addressTypeError.getErrorCode(),
e.getCode());
}
}
示例8: validateAssignRoleWithProviderAndExternalId
import org.sunbird.common.exception.ProjectCommonException; //导入依赖的package包/类
@Test
public void validateAssignRoleWithProviderAndExternalId () {
Request request = new Request();
boolean response = false;
Map<String, Object> requestObj = new HashMap<>();
requestObj.put(JsonKey.PROVIDER, "ORG-provider");
requestObj.put(JsonKey.EXTERNAL_ID, "ORG-1233");
List<String> roles = new ArrayList<>();
roles.add("PUBLIC");
requestObj.put(JsonKey.ROLES, roles);
request.setRequest(requestObj);
try {
RequestValidator.validateAssignRole(request);
response = true;
} catch (ProjectCommonException e) {
Assert.assertNull(e);
}
assertEquals(true, response);
}
示例9: testCreateNoteBlankUserId
import org.sunbird.common.exception.ProjectCommonException; //导入依赖的package包/类
/**
* Method to test create note when userId in request is empty
*/
@Test
public void testCreateNoteBlankUserId() {
try {
Request request = new Request();
Map<String, Object> requestObj = new HashMap<>();
requestObj.put(JsonKey.USER_ID, "");
requestObj.put(JsonKey.TITLE, "test title");
requestObj.put(JsonKey.NOTE, "This is a test Note");
requestObj.put(JsonKey.COURSE_ID, "org.ekstep.test");
requestObj.put(JsonKey.CONTENT_ID, "org.ekstep.test");
request.setRequest(requestObj);
RequestValidator.validateNote(request);
} catch (ProjectCommonException e) {
assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode());
assertEquals(ResponseCode.userIdRequired.getErrorCode(), e.getCode());
}
}
示例10: validateUpdateSection
import org.sunbird.common.exception.ProjectCommonException; //导入依赖的package包/类
/**
* This method will validate update section request data
*
* @param request Request
*/
public static void validateUpdateSection(Request request) {
if (ProjectUtil
.isStringNullOREmpty((String) (request.getRequest().get(JsonKey.SECTION_NAME) != null
? request.getRequest().get(JsonKey.SECTION_NAME) : ""))) {
throw new ProjectCommonException(ResponseCode.sectionNameRequired.getErrorCode(),
ResponseCode.sectionNameRequired.getErrorMessage(), ERROR_CODE);
}
if (ProjectUtil.isStringNullOREmpty((String) (request.getRequest().get(JsonKey.ID) != null
? request.getRequest().get(JsonKey.ID) : ""))) {
throw new ProjectCommonException(ResponseCode.sectionIdRequired.getErrorCode(),
ResponseCode.sectionIdRequired.getErrorMessage(), ERROR_CODE);
}
if (ProjectUtil
.isStringNullOREmpty((String) (request.getRequest().get(JsonKey.SECTION_DATA_TYPE) != null
? request.getRequest().get(JsonKey.SECTION_DATA_TYPE) : ""))) {
throw new ProjectCommonException(ResponseCode.sectionDataTypeRequired.getErrorCode(),
ResponseCode.sectionDataTypeRequired.getErrorMessage(), ERROR_CODE);
}
}
示例11: createNote
import org.sunbird.common.exception.ProjectCommonException; //导入依赖的package包/类
/**
* Method to create Note
* @return Promise<Result>
*/
public Promise<Result> createNote() {
try {
JsonNode requestData = request().body().asJson();
ProjectLogger.log("Create note request: " + requestData, LoggerEnum.INFO.name());
Request reqObj = (Request) mapper.RequestMapper.mapRequest(requestData, Request.class);
if(null != ctx().flash().get(JsonKey.IS_AUTH_REQ) && Boolean.parseBoolean(ctx().flash().get(JsonKey.IS_AUTH_REQ))){
String userId = (String) reqObj.get(JsonKey.USER_ID);
if((!ProjectUtil.isStringNullOREmpty(userId)) && (!userId.equals(ctx().flash().get(JsonKey.USER_ID)))){
throw new ProjectCommonException(ResponseCode.unAuthorised.getErrorCode(), ResponseCode.unAuthorised.getErrorMessage(), ResponseCode.UNAUTHORIZED.getResponseCode());
}
}
RequestValidator.validateNote(reqObj);
reqObj.setOperation(ActorOperations.CREATE_NOTE.getValue());
reqObj.setRequestId(ExecutionContext.getRequestId());
reqObj.setEnv(getEnvironment());
HashMap<String, Object> innerMap = new HashMap<>();
innerMap.put(JsonKey.NOTE, reqObj.getRequest());
innerMap.put(JsonKey.REQUESTED_BY,ctx().flash().get(JsonKey.USER_ID));
reqObj.setRequest(innerMap);
return actorResponseHandler(getActorRef(), reqObj, timeout, null, null);
} catch (Exception e) {
ProjectLogger.log("Error in controller", e);
return Promise.<Result>pure(createCommonExceptionResponse(e, null));
}
}
示例12: validatePhoneNoTest
import org.sunbird.common.exception.ProjectCommonException; //导入依赖的package包/类
@Test
public void validatePhoneNoTest(){
Request request = new Request();
request.getRequest().put(JsonKey.EMAIL, "[email protected]");
request.getRequest().put(JsonKey.PHONE, "9874561230");
request.getRequest().put(JsonKey.COUNTRY_CODE, "+001");
request.getRequest().put(JsonKey.USERNAME, "98745");
request.getRequest().put(JsonKey.FIRST_NAME, "98745");
try {
RequestValidator.validateCreateUser(request);
} catch (ProjectCommonException e) {
assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(),
e.getResponseCode());
assertEquals(ResponseCode.phoneNoFormatError.getErrorCode(),
e.getCode());
}
}
示例13: educationValidationTest2
import org.sunbird.common.exception.ProjectCommonException; //导入依赖的package包/类
@Test
public void educationValidationTest2(){
Request request = new Request();
request.getRequest().put(JsonKey.EMAIL, "[email protected]");
request.getRequest().put(JsonKey.PHONE, "9874561230");
request.getRequest().put(JsonKey.USERNAME, "98745");
request.getRequest().put(JsonKey.FIRST_NAME, "98745");
Map<String,Object> map = new HashMap<>();
map.put(JsonKey.NAME, "name");
map.put(JsonKey.DEGREE, "");
List<Map<String,Object>> list = new ArrayList<>();
list.add(map);
request.getRequest().put(JsonKey.EDUCATION, list);
try {
RequestValidator.validateCreateUser(request);
} catch (ProjectCommonException e) {
assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(),
e.getResponseCode());
assertEquals(ResponseCode.educationDegreeError.getErrorCode(),
e.getCode());
}
}
示例14: UpdateKeyCloakUserBase
import org.sunbird.common.exception.ProjectCommonException; //导入依赖的package包/类
private void UpdateKeyCloakUserBase(Map<String, Object> userMap) {
try {
String userId = ssoManager.updateUser(userMap);
if (!(!ProjectUtil.isStringNullOREmpty(userId) && userId.equalsIgnoreCase(JsonKey.SUCCESS))) {
throw new ProjectCommonException(ResponseCode.userUpdationUnSuccessfull.getErrorCode(),
ResponseCode.userUpdationUnSuccessfull.getErrorMessage(),
ResponseCode.SERVER_ERROR.getResponseCode());
}else if(!ProjectUtil.isStringNullOREmpty((String) userMap.get(JsonKey.EMAIL))){
//if Email is Null or Empty , it means we are not updating email
Util.DbInfo usrDbInfo = Util.dbInfoMap.get(JsonKey.USER_DB);
Map<String,Object> map = new HashMap<>();
map.put(JsonKey.ID, userId);
map.put(JsonKey.EMAIL_VERIFIED, false);
cassandraOperation.updateRecord(usrDbInfo.getKeySpace(),
usrDbInfo.getTableName(), map);
}
} catch (Exception e) {
ProjectLogger.log(e.getMessage(), e);
throw new ProjectCommonException(ResponseCode.userUpdationUnSuccessfull.getErrorCode(),
ResponseCode.userUpdationUnSuccessfull.getErrorMessage(),
ResponseCode.SERVER_ERROR.getResponseCode());
}
}
示例15: testCUpdatePageWithOrgIdWithSameName
import org.sunbird.common.exception.ProjectCommonException; //导入依赖的package包/类
@Test
public void testCUpdatePageWithOrgIdWithSameName(){
TestKit probe = new TestKit(system);
ActorRef subject = system.actorOf(props);
Request reqObj = new Request();
reqObj.setOperation(ActorOperations.UPDATE_PAGE.getValue());
HashMap<String, Object> innerMap = new HashMap<>();
Map<String , Object> pageMap = new HashMap<String , Object>();
pageMap.put(JsonKey.PAGE_NAME, "Test Page");
pageMap.put(JsonKey.ID, pageIdWithOrg2);
innerMap.put(JsonKey.PAGE , pageMap);
reqObj.setRequest(innerMap);
subject.tell(reqObj, probe.getRef());
probe.expectMsgClass(duration("100 second"),ProjectCommonException.class);
}