REST Resources

You can define new REST resources in the EPT project and use those without restarting the server. All REST resources should go into the <EptSourcePackage>.rest. package. You can define any number of REST classes but care should be taken to use the unique and different resource path to avoid any conflicts.

Afer defining rest resource, you can submit it as part of your EPT and will be accessible using http://localhost/oms/rest/EPT/<EptName>/<Resource Path>, i.e. http://localhost/oms/rest/EPT/SampleEnterprise/sample

import org.json.JSONObject;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import com.onenetwork.platform.common.usercontext.PlatformUserContext;
 * Sample REST resource.  Will be available at /oms/rest/eptName/sample
public class SampleResource extends BaseResource {
	public JSONObject getSample() {
		JSONObject result = new JSONObject();
		PlatformUserContext userContext = getPlatformUserContext();
		return result.put("username", userContext.getUserName());