-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #130 from project-sunbird/SB-6890
Sb 6890
- Loading branch information
Showing
8 changed files
with
157 additions
and
2 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
actor-util/src/main/java/org/sunbird/actorutil/systemsettings/SystemSettingClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package org.sunbird.actorutil.systemsettings; | ||
|
||
import akka.actor.ActorRef; | ||
import org.sunbird.models.systemsetting.SystemSetting; | ||
|
||
/** | ||
* This interface defines methods supported by System Setting service. | ||
* | ||
* @author Amit Kumar | ||
*/ | ||
public interface SystemSettingClient { | ||
|
||
/** | ||
* @desc Get system setting information for given field (setting) name. | ||
* @param actorRef Actor reference. | ||
* @param field System setting field name. | ||
* @return System setting details | ||
*/ | ||
SystemSetting getSystemSettingByField(ActorRef actorRef, String field); | ||
} |
57 changes: 57 additions & 0 deletions
57
...util/src/main/java/org/sunbird/actorutil/systemsettings/impl/SystemSettingClientImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package org.sunbird.actorutil.systemsettings.impl; | ||
|
||
import akka.actor.ActorRef; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
import org.sunbird.actorutil.InterServiceCommunication; | ||
import org.sunbird.actorutil.InterServiceCommunicationFactory; | ||
import org.sunbird.actorutil.systemsettings.SystemSettingClient; | ||
import org.sunbird.common.exception.ProjectCommonException; | ||
import org.sunbird.common.models.response.Response; | ||
import org.sunbird.common.models.util.ActorOperations; | ||
import org.sunbird.common.models.util.JsonKey; | ||
import org.sunbird.common.models.util.LoggerEnum; | ||
import org.sunbird.common.models.util.ProjectLogger; | ||
import org.sunbird.common.request.Request; | ||
import org.sunbird.common.responsecode.ResponseCode; | ||
import org.sunbird.models.systemsetting.SystemSetting; | ||
|
||
public class SystemSettingClientImpl implements SystemSettingClient { | ||
|
||
private static InterServiceCommunication interServiceCommunication = | ||
InterServiceCommunicationFactory.getInstance(); | ||
private static SystemSettingClientImpl systemSettingClient = null; | ||
|
||
public static SystemSettingClientImpl getInstance() { | ||
if (null == systemSettingClient) { | ||
systemSettingClient = new SystemSettingClientImpl(); | ||
} | ||
return systemSettingClient; | ||
} | ||
|
||
@Override | ||
public SystemSetting getSystemSettingByField(ActorRef actorRef, String field) { | ||
return getSystemSetting(actorRef, JsonKey.FIELD, field); | ||
} | ||
|
||
private SystemSetting getSystemSetting(ActorRef actorRef, String param, Object value) { | ||
Request request = new Request(); | ||
Map<String, Object> map = new HashMap<>(); | ||
map.put(param, value); | ||
request.setRequest(map); | ||
request.setOperation(ActorOperations.GET_SYSTEM_SETTING.getValue()); | ||
ProjectLogger.log("SystemSettingClientImpl: getSystemSetting called", LoggerEnum.INFO); | ||
Object obj = interServiceCommunication.getResponse(actorRef, request); | ||
if (obj instanceof Response) { | ||
Response responseObj = (Response) obj; | ||
return (SystemSetting) responseObj.getResult().get(JsonKey.RESPONSE); | ||
} else if (obj instanceof ProjectCommonException) { | ||
throw (ProjectCommonException) obj; | ||
} else { | ||
throw new ProjectCommonException( | ||
ResponseCode.SERVER_ERROR.getErrorCode(), | ||
ResponseCode.SERVER_ERROR.getErrorMessage(), | ||
ResponseCode.SERVER_ERROR.getResponseCode()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
models/src/main/java/org/sunbird/models/systemsetting/SystemSetting.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package org.sunbird.models.systemsetting; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import com.fasterxml.jackson.annotation.JsonInclude.Include; | ||
import java.io.Serializable; | ||
|
||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
@JsonInclude(Include.NON_NULL) | ||
public class SystemSetting implements Serializable { | ||
private static final long serialVersionUID = 1L; | ||
private String id; | ||
private String field; | ||
private String value; | ||
|
||
public SystemSetting() {} | ||
|
||
public SystemSetting(String id, String field, String value) { | ||
this.id = id; | ||
this.field = field; | ||
this.value = value; | ||
} | ||
|
||
public String getId() { | ||
return this.id; | ||
} | ||
|
||
public String getField() { | ||
return this.field; | ||
} | ||
|
||
public String getValue() { | ||
return this.value; | ||
} | ||
|
||
public void setId(String id) { | ||
this.id = id; | ||
} | ||
|
||
public void setField(String field) { | ||
this.field = field; | ||
} | ||
|
||
public void setValue(String value) { | ||
this.value = value; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters