Java 类javax.ws.rs.CookieParam 实例源码
项目:acmeair-modular
文件:CustomerREST.java
@GET
@Path("/byid/{custid}")
@Produces("text/plain")
public Response getCustomer(@CookieParam("sessionid") String sessionid, @PathParam("custid") String customerid) {
if(logger.isLoggable(Level.FINE)){
logger.fine("getCustomer : session ID " + sessionid + " userid " + customerid);
}
try {
// make sure the user isn't trying to update a customer other than the one currently logged in
if (!validate(customerid)) {
return Response.status(Response.Status.FORBIDDEN).build();
}
return Response.ok(customerService.getCustomerByUsername(customerid)).build();
}
catch (Exception e) {
e.printStackTrace();
return null;
}
}
项目:acmeair-modular
文件:CustomerREST.java
@POST
@Path("/byid/{custid}")
@Produces("text/plain")
public /* Customer */ Response putCustomer(@CookieParam("sessionid") String sessionid, CustomerInfo customer) {
String username = customer.getUsername();
if (!validate(username)) {
return Response.status(Response.Status.FORBIDDEN).build();
}
String customerFromDB = customerService.getCustomerByUsernameAndPassword(username, customer.getPassword());
if(logger.isLoggable(Level.FINE)){
logger.fine("putCustomer : " + customerFromDB);
}
if (customerFromDB == null) {
// either the customer doesn't exist or the password is wrong
return Response.status(Response.Status.FORBIDDEN).build();
}
customerService.updateCustomer(username, customer);
//Retrieve the latest results
customerFromDB = customerService.getCustomerByUsernameAndPassword(username, customer.getPassword());
return Response.ok(customerFromDB).build();
}
项目:acmeair-modular
文件:CustomerREST.java
@GET
@Path("/byid/{custid}")
@Produces("text/plain")
public Response getCustomer(@CookieParam("sessionid") String sessionid, @PathParam("custid") String customerid) {
if(logger.isLoggable(Level.FINE)){
logger.fine("getCustomer : session ID " + sessionid + " userid " + customerid);
}
try {
// make sure the user isn't trying to update a customer other than the one currently logged in
if (!validate(customerid)) {
return Response.status(Response.Status.FORBIDDEN).build();
}
return Response.ok(customerService.getCustomerByUsername(customerid)).build();
}
catch (Exception e) {
e.printStackTrace();
return null;
}
}
项目:acmeair-modular
文件:CustomerREST.java
@POST
@Path("/byid/{custid}")
@Produces("text/plain")
public Response putCustomer(@CookieParam("sessionid") String sessionid, CustomerInfo customer) {
String username = customer.getUsername();
if (!validate(username)) {
return Response.status(Response.Status.FORBIDDEN).build();
}
String customerFromDB = customerService.getCustomerByUsernameAndPassword(username, customer.getPassword());
if(logger.isLoggable(Level.FINE)){
logger.fine("putCustomer : " + customerFromDB);
}
if (customerFromDB == null) {
// either the customer doesn't exist or the password is wrong
return Response.status(Response.Status.FORBIDDEN).build();
}
customerService.updateCustomer(username, customer);
//Retrieve the latest results
customerFromDB = customerService.getCustomerByUsernameAndPassword(username, customer.getPassword());
return Response.ok(customerFromDB).build();
}
项目:crnk-framework
文件:CookieParamProvider.java
@Override
public Object provideValue(Parameter parameter, ContainerRequestContext requestContext, ObjectMapper objectMapper) {
Object returnValue;
String cookieName = parameter.getAnnotation(CookieParam.class).value();
Cookie cookie = requestContext.getCookies().get(cookieName);
if (cookie == null) {
return null;
} else {
if (Cookie.class.isAssignableFrom(parameter.getType())) {
returnValue = cookie;
} else if (String.class.isAssignableFrom(parameter.getType())) {
returnValue = cookie.getValue();
} else {
try {
returnValue = objectMapper.readValue(cookie.getValue(), parameter.getType());
} catch (IOException e) {
throw new IllegalStateException(e);
}
}
}
return returnValue;
}
项目:plugin-redirect
文件:RedirectResource.java
/**
* Handle redirect request using cookie (checked, and updated), and the
* stored preferred URL.
*
* @param cookieHash
* the optional stored cookie URL.
* @return the computed redirect URL.
*/
@GET
public Response handleRedirect(@CookieParam(PREFERRED_COOKIE_HASH) final String cookieHash) throws URISyntaxException {
// Check the user is authenticated or not
final String user = securityHelper.getLogin();
if (isAnonymous(user)) {
// Anonymous request, use the cookie hash to retrieve the user's
// preferred URL
return redirect(getUrlFromCookie(cookieHash)).build();
}
// Authenticated user, use preferred URL if defined, and also republish
// the hash value
final Map<String, Object> settings = userSettingResource.findAll(user);
return addCookie(redirect((String) settings.get(PREFERRED_URL)), user, (String) settings.get(PREFERRED_HASH)).build();
}
项目:acmeair
文件:LoginREST.java
@GET
@Path("/logout")
@Produces("text/plain")
@ApiResponses(value = { @ApiResponse(code = 500, message = "CustomerService Internal Server Error") })
public String logout(@QueryParam("login") String login, @CookieParam("sessionid") String sessionid) {
try {
customerService.invalidateSession(sessionid);
// The following call will trigger query against all partitions, disable for now
// customerService.invalidateAllUserSessions(login);
// TODO: Want to do this with setMaxAge to zero, but to do that I need to have the same path/domain as cookie
// created in login. Unfortunately, until we have a elastic ip and domain name its hard to do that for "localhost".
// doing this will set the cookie to the empty string, but the browser will still send the cookie to future requests
// and the server will need to detect the value is invalid vs actually forcing the browser to time out the cookie and
// not send it to begin with
// NewCookie sessCookie = new NewCookie(SESSIONID_COOKIE_NAME, "");
return "logged out";
}
catch (Exception e) {
throw new InvocationException(Status.INTERNAL_SERVER_ERROR, "Internal Server Error");
}
}
项目:jee-demo
文件:WebServiceEndpointIntrospection.java
private static String getParamName(Object paramAnnotation) {
if (paramAnnotation instanceof FormParam) {
return ((FormParam) paramAnnotation).value();
}
if (paramAnnotation instanceof HeaderParam) {
return ((HeaderParam) paramAnnotation).value();
}
if (paramAnnotation instanceof PathParam) {
return ((PathParam) paramAnnotation).value();
}
if (paramAnnotation instanceof QueryParam) {
return ((QueryParam) paramAnnotation).value();
}
if (paramAnnotation instanceof CookieParam) {
return ((CookieParam) paramAnnotation).value();
}
return "?";
}
项目:ozark
文件:MvcConverterProvider.java
private static String getParamName(Annotation[] annotations) {
for (Annotation annotation : annotations) {
if (annotation instanceof QueryParam) {
return ((QueryParam) annotation).value();
}
if (annotation instanceof PathParam) {
return ((PathParam) annotation).value();
}
if (annotation instanceof FormParam) {
return ((FormParam) annotation).value();
}
if (annotation instanceof MatrixParam) {
return ((MatrixParam) annotation).value();
}
if (annotation instanceof CookieParam) {
return ((CookieParam) annotation).value();
}
}
return null;
}
项目:ozark
文件:ConstraintViolationMetadata.java
public Optional<String> getParamName() {
for (Annotation annotation : annotations) {
if (annotation instanceof QueryParam) {
return Optional.of(((QueryParam) annotation).value());
}
if (annotation instanceof PathParam) {
return Optional.of(((PathParam) annotation).value());
}
if (annotation instanceof FormParam) {
return Optional.of(((FormParam) annotation).value());
}
if (annotation instanceof MatrixParam) {
return Optional.of(((MatrixParam) annotation).value());
}
if (annotation instanceof CookieParam) {
return Optional.of(((CookieParam) annotation).value());
}
}
return Optional.empty();
}
项目:katharsis-framework
文件:CookieParamProvider.java
@Override
public Object provideValue(Parameter parameter, ContainerRequestContext requestContext, ObjectMapper objectMapper) {
Object returnValue;
String cookieName = parameter.getAnnotation(CookieParam.class).value();
Cookie cookie = requestContext.getCookies().get(cookieName);
if (cookie == null) {
return null;
} else {
if (Cookie.class.isAssignableFrom(parameter.getType())) {
returnValue = cookie;
} else if (String.class.isAssignableFrom(parameter.getType())) {
returnValue = cookie.getValue();
} else {
try {
returnValue = objectMapper.readValue(cookie.getValue(), parameter.getType());
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}
return returnValue;
}
项目:product-ei
文件:StockQuoteService.java
/**
* Retrieve a stock for a given symbol using a cookie.
* This method demonstrates the CookieParam JAXRS annotation in action.
*
* curl -v --header "Cookie: symbol=IBM" http://localhost:9090/stockquote
*
* @param symbol Stock symbol will be taken from the symbol cookie.
* @return Response
*/
@GET
@Produces({"application/json", "text/xml"})
@ApiOperation(
value = "Return stock quote corresponding to the symbol",
notes = "Returns HTTP 404 if the symbol is not found")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Valid stock item found"),
@ApiResponse(code = 404, message = "Stock item not found")})
public Response getQuoteUsingCookieParam(@ApiParam(value = "Symbol", required = true)
@CookieParam("symbol") String symbol) throws SymbolNotFoundException {
Stock stock = stockQuotes.get(symbol);
if (stock == null) {
throw new SymbolNotFoundException("Symbol " + symbol + " not found");
}
return Response.ok().entity(stock).build();
}
项目:resteasy-examples
文件:CustomerResource.java
@GET
@Path("{id}")
@Produces("text/plain")
public Response getCustomer(@PathParam("id") int id,
@HeaderParam("User-Agent") String userAgent,
@CookieParam("last-visit") String date)
{
final Customer customer = customerDB.get(id);
if (customer == null)
{
throw new WebApplicationException(Response.Status.NOT_FOUND);
}
String output = "User-Agent: " + userAgent + "\r\n";
output += "Last visit: " + date + "\r\n\r\n";
output += "Customer: " + customer.getFirstName() + " " + customer.getLastName();
String lastVisit = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.LONG).format(new Date());
return Response.ok(output)
.cookie(new NewCookie("last-visit", lastVisit))
.build();
}
项目:resteasy-examples
文件:CustomerResource.java
@GET
@Path("{id}")
@Produces("text/plain")
public Response getCustomer(@PathParam("id") int id,
@HeaderParam("User-Agent") String userAgent,
@CookieParam("last-visit") String date)
{
final Customer customer = customerDB.get(id);
if (customer == null)
{
throw new WebApplicationException(Response.Status.NOT_FOUND);
}
String output = "User-Agent: " + userAgent + "\r\n";
output += "Last visit: " + date + "\r\n\r\n";
output += "Customer: " + customer.getFirstName() + " " + customer.getLastName();
String lastVisit = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.LONG).format(new Date());
return Response.ok(output)
.cookie(new NewCookie("last-visit", lastVisit))
.build();
}
项目:resteasy-examples
文件:MyResource.java
@Path("foo/{param}-{other}")
@GET
public String getFooParam(@PathParam("param") String param,
@PathParam("other") String other,
@QueryParam("q") String q,
@CookieParam("c") String c,
@HeaderParam("h") String h,
@MatrixParam("m") String m,
@Context UriInfo ignore)
{
StringBuffer buf = new StringBuffer();
buf.append("param").append("=").append(param).append(";");
buf.append("other").append("=").append(other).append(";");
buf.append("q").append("=").append(q).append(";");
buf.append("c").append("=").append(c).append(";");
buf.append("h").append("=").append(h).append(";");
buf.append("m").append("=").append(m).append(";");
return buf.toString();
}
项目:resteasy-examples
文件:MyResource.java
@Path("foo/{param}-{other}")
@PUT
public String putFooParam(@PathParam("param") String param,
@PathParam("other") String other,
@QueryParam("q") String q,
@CookieParam("c") String c,
@HeaderParam("h") String h,
@MatrixParam("m") String m,
String entity,
@Context UriInfo ignore)
{
StringBuffer buf = new StringBuffer();
buf.append("param").append("=").append(param).append(";");
buf.append("other").append("=").append(other).append(";");
buf.append("q").append("=").append(q).append(";");
buf.append("c").append("=").append(c).append(";");
buf.append("h").append("=").append(h).append(";");
buf.append("m").append("=").append(m).append(";");
buf.append("entity").append("=").append(entity).append(";");
return buf.toString();
}
项目:keywhiz
文件:SessionLogoutResource.java
/**
* Logout and remove any session cookies
*
* @description Log out and remove any session cookies
* @responseMessage 200 Logged out successfully
*/
@Timed @ExceptionMetered
@POST
@Produces(APPLICATION_JSON)
public Response logout(@Nullable @CookieParam(value = "session") Cookie sessionCookie) {
if (sessionCookie != null) {
Optional<User> user = cookieAuthenticator.authenticate(sessionCookie);
if (user.isPresent()) {
logger.info("User logged out: {}", user.get().getName());
} else {
logger.warn("Invalid user cookie on logout.");
}
}
NewCookie expiredCookie = cookieFactory.getExpiredSessionCookie();
return Response.ok()
.header(HttpHeaders.SET_COOKIE, expiredCookie.toString())
.build();
}
项目:msf4j
文件:StockQuoteService.java
/**
* Retrieve a stock for a given symbol using a cookie.
* This method demonstrates the CookieParam JAXRS annotation in action.
*
* curl -v --header "Cookie: symbol=IBM" http://localhost:8080/stockquote
*
* @param symbol Stock symbol will be taken from the symbol cookie.
* @return Response
*/
@GET
@Produces({"application/json", "text/xml"})
@ApiOperation(
value = "Return stock quote corresponding to the symbol",
notes = "Returns HTTP 404 if the symbol is not found")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Valid stock item found"),
@ApiResponse(code = 404, message = "Stock item not found")})
public Response getQuoteUsingCookieParam(@ApiParam(value = "Symbol", required = true)
@CookieParam("symbol") String symbol) throws SymbolNotFoundException {
Stock stock = stockQuotes.get(symbol);
if (stock == null) {
throw new SymbolNotFoundException("Symbol " + symbol + " not found");
}
return Response.ok().entity(stock).build();
}
项目:msf4j
文件:StockQuoteService.java
/**
* Retrieve a stock for a given symbol using a cookie.
* This method demonstrates the CookieParam JAXRS annotation in action.
*
* curl -v --header "Cookie: symbol=IBM" http://localhost:8080/stockquote
*
* @param symbol Stock symbol will be taken from the symbol cookie.
* @return Response
*/
@GET
@Produces({"application/json", "text/xml"})
@ApiOperation(
value = "Return stock quote corresponding to the symbol",
notes = "Returns HTTP 404 if the symbol is not found")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Valid stock item found"),
@ApiResponse(code = 404, message = "Stock item not found")})
public Response getQuoteUsingCookieParam(@ApiParam(value = "Symbol", required = true)
@CookieParam("symbol") String symbol) throws SymbolNotFoundException {
System.out.println("Getting symbol using CookieParam...");
Stock stock = stockQuotes.get(symbol);
if (stock == null) {
throw new SymbolNotFoundException("Symbol " + symbol + " not found");
}
return Response.ok().entity(stock).build();
}
项目:typescript-generator
文件:JaxrsApplicationParser.java
private static MethodParameterModel getEntityParameter(Method method) {
for (Parameter parameter : method.getParameters()) {
if (!hasAnyAnnotation(parameter, Arrays.asList(
MatrixParam.class,
QueryParam.class,
PathParam.class,
CookieParam.class,
HeaderParam.class,
Context.class,
FormParam.class
))) {
return new MethodParameterModel(parameter.getName(), parameter.getParameterizedType());
}
}
return null;
}
项目:HotSpots
文件:Index.java
@GET
@Produces(MediaType.TEXT_HTML)
public Response doGetHTML( @Context UriInfo ui,
@Context SecurityContext context,
@CookieParam("token") String token)
{
Response result = null;
String html = null;
try {
html = FileUtils.readFileToString(new File("ui/index.html"));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
result = Response.ok().entity(html).build();
return result;
}
项目:karuta-backend
文件:RestServicePortfolio.java
/**
* elgg related
* POST /rest/api/elgg/wire
* parameters:
* return:
**/
@Path("/elgg/wire")
@POST
@Produces(MediaType.APPLICATION_XML)
public String getElggSiteRiverFeed(String message, @CookieParam("user") String user, @CookieParam("credential") String token, @CookieParam("group") String group, @Context ServletConfig sc,@Context HttpServletRequest httpServletRequest,
@QueryParam("type") Integer type)
{
UserInfo ui = checkCredential(httpServletRequest, user, token, null);
try
{
Elgg elgg = new Elgg(elggDefaultApiUrl,elggDefaultSiteUrl,elggApiKey,ui.User, elggDefaultUserPassword);
return elgg.postWire(message);
}
catch(Exception ex)
{
ex.printStackTrace();
logRestRequest(httpServletRequest, "",javaUtils.getCompleteStackTrace(ex), Status.INTERNAL_SERVER_ERROR.getStatusCode());
throw new RestWebApplicationException(Status.INTERNAL_SERVER_ERROR, ex.getMessage());
}
}
项目:stdlib
文件:RestServiceResourceParamInfo.java
@SuppressWarnings("unchecked")
public boolean isEntity()
{
// Not if it has any Path/Query/Form params
if (hasAnnotations(PathParam.class,
QueryParam.class,
FormParam.class,
HeaderParam.class,
CookieParam.class))
return false;
// Not if this comes from the JAX-RS context and not the request
if (hasAnnotation(Context.class))
return false;
// Not if it's a javax.ws.rs type
if (clazz.getPackage() != null && clazz.getPackage().getName().startsWith("javax.ws.rs"))
return false;
// has not been excluded, assume this is the entity
return true;
}
项目:semanticMDR
文件:PropertyService.java
@GET
@Produces(MediaType.APPLICATION_JSON)
public Response getProperty(
@CookieParam(AuthenticationService.SID) String sessionID,
@PathParam("propertyid") String propertyID) {
WebUtil.checkUserSession(sessionID);
Repository repository = RepositoryManager.getInstance().getRepository();
MDRDatabase mdrDatabase = repository.getMDRDatabase();
Property property = new PropertyImpl(mdrDatabase.getOntModel()
.getResource(
mdrDatabase.getResourceFactory().makeID(
Abbreviation.Property.toString(), propertyID)),
mdrDatabase);
return Response.ok(new PropertyModel(property)).build();
}
项目:semanticMDR
文件:DataElementConceptService.java
@GET
@Path("/de")
@Produces(MediaType.APPLICATION_JSON)
public Response listDataElements(
@CookieParam(AuthenticationService.SID) String sessionID,
@PathParam("decid") String decID) {
WebUtil.checkUserSession(sessionID);
Repository repository = RepositoryManager.getInstance().getRepository();
DataElementConcept dec = repository.getDataElementConcept(decID);
List<DataElement> deList = dec.getDataElements();
List<DataElementModel> deModelList = new ArrayList<DataElementModel>();
for (DataElement de : deList) {
deModelList.add(new DataElementModel(de));
}
return Response.ok(deModelList).build();
}
项目:semanticMDR
文件:ValueDomainService.java
@GET
@Produces(MediaType.APPLICATION_JSON)
public Response getValueDomain(
@CookieParam(AuthenticationService.SID) String sessionID,
@PathParam("vdid") String valueDomainID) {
WebUtil.checkUserSession(sessionID);
Repository repository = RepositoryManager.getInstance().getRepository();
ValueDomain vd = repository.getValueDomain(valueDomainID);
if (vd == null) {
return Response.noContent().build();
}
if (vd instanceof EnumeratedValueDomain) {
return Response.ok(new ValueDomainModel(vd, true)).build();
} else {
return Response.ok(new ValueDomainModel(vd, false)).build();
}
}
项目:semanticMDR
文件:DataElementService.java
@DELETE
public Response deleteDataElement(
@CookieParam(AuthenticationService.SID) String sessionID,
@PathParam("deid") String dataElementID) {
WebUtil.checkUserSession(sessionID);
Repository repository = RepositoryManager.getInstance().getRepository();
DataElement de = repository.getDataElement(dataElementID);
// TODO which relations of Data Element is to be deleted, decide on that
try {
de.delete();
} catch (Exception e) {
return Response.serverError().build();
}
return Response.ok().build();
}
项目:semanticMDR
文件:DataElementService.java
@POST
@Path("/mapping")
public Response addMapping(
@CookieParam(AuthenticationService.SID) String sessionID,
@PathParam("deid") String dataElementID, MappingModel mapping) {
WebUtil.checkUserSession(sessionID);
Repository repository = RepositoryManager.getInstance().getRepository();
DataElement de = repository.getDataElement(dataElementID);
DataElement mappedDE = repository.getDataElement(mapping.getTermUUID());
MappingRelation relation = new MappingRelation();
relation.setSubjectOID(MDRConstants.getOIDFromContentModel(de.getContext().getName()));
relation.setRelationType(mapping.getMatchType());
relation.setObjectOID(mapping.getTermSystemOID());
de.addMapping(relation, mappedDE);
logger.debug("{} --> {} mapping is added", dataElementID,
mapping.getTermUUID());
return Response.ok().build();
}
项目:semanticMDR
文件:DataElementService.java
@POST
@Path("/extractionspecification")
public Response addExtractionSpecification(
@CookieParam(AuthenticationService.SID) String sessionID,
@PathParam("deid") String dataElementID,
ExtractionSpecificationModel extractionSpecification) {
WebUtil.checkUserSession(sessionID);
Repository repository = RepositoryManager.getInstance().getRepository();
DataElement de = repository.getDataElement(dataElementID);
de.addExtractionSpecification(extractionSpecification.getModelOID(),
extractionSpecification.getType(),
extractionSpecification.getValue());
logger.debug("{} is added to {} as Extraction Specification",
extractionSpecification.getValue(), dataElementID);
return Response.ok().build();
}
项目:semanticMDR
文件:RepositoryService.java
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response createContext(
@CookieParam(AuthenticationService.SID) String sessionID,
ContextModel contextModel) {
User user = WebUtil.getUser(sessionID);
Repository repository = RepositoryManager.getInstance().getRepository();
Contact contact = repository.getContact(user.getFullName());
Organization organization = repository.getOrganization(user
.getAffiliation().getName());
Context context = repository.createContext(contextModel.getName(),
contextModel.getDefinition(), contact, organization);
return Response.ok(new ContextModel(context)).build();
}
项目:semanticMDR
文件:RepositoryService.java
@Path("/search")
@GET
@Produces(MediaType.APPLICATION_JSON)
public Response searchDataElements(
@CookieParam(AuthenticationService.SID) String sessionID,
@QueryParam("q") String keyword,
@QueryParam("limit") @DefaultValue("10") Integer limit,
@QueryParam("offset") @DefaultValue("0") Integer offset) {
WebUtil.checkUserSession(sessionID);
Repository repository = RepositoryManager.getInstance().getRepository();
List<DataElement> deList = repository.searchDataElement(keyword,
TextSearchType.WildCard, limit, offset);
List<DataElementModel> deModelList = new ArrayList<DataElementModel>();
for (DataElement de : deList) {
deModelList.add(new DataElementModel(de));
}
return Response.ok(deModelList).build();
}
项目:semanticMDR
文件:RepositoryService.java
@GET
@Path("/cd")
@Produces(MediaType.APPLICATION_JSON)
public Response listConceptualDomains(
@CookieParam(AuthenticationService.SID) String sessionID,
@QueryParam("limit") @DefaultValue("10") Integer limit,
@QueryParam("offset") @DefaultValue("0") Integer offset) {
WebUtil.checkUserSession(sessionID);
Repository repository = RepositoryManager.getInstance().getRepository();
List<ConceptualDomain> cdList = repository.getConceptualDomains(limit,
offset);
List<ConceptualDomainModel> cdModelList = new ArrayList<ConceptualDomainModel>();
for (ConceptualDomain cd : cdList) {
if (cd instanceof EnumeratedConceptualDomain) {
cdModelList.add(new ConceptualDomainModel(cd, true));
} else {
cdModelList.add(new ConceptualDomainModel(cd, false));
}
}
return Response.ok(cdModelList).build();
}
项目:semanticMDR
文件:RepositoryService.java
@PUT
@Path("/cd")
@Consumes(MediaType.APPLICATION_JSON)
public Response updateConceptualDomain(
@CookieParam(AuthenticationService.SID) String sessionID,
ConceptualDomainModel cdModel) {
WebUtil.checkUserSession(sessionID);
Repository repository = RepositoryManager.getInstance().getRepository();
ConceptualDomain conceptualDomain = repository
.getConceptualDomain(cdModel.getId());
// Currently, only name, definition and dimensionality can be updated
conceptualDomain.setName(cdModel.getName());
conceptualDomain.setDefinition(cdModel.getDefinition());
conceptualDomain.setDimensionality(cdModel.getDimensionality());
return Response.ok().build();
}
项目:semanticMDR
文件:RepositoryService.java
@GET
@Path("/cd/search")
@Produces(MediaType.APPLICATION_JSON)
public Response searchConceptualDomain(
@CookieParam(AuthenticationService.SID) String sessionID,
@QueryParam("q") String keyword) {
WebUtil.checkUserSession(sessionID);
Repository repository = RepositoryManager.getInstance().getRepository();
List<ConceptualDomain> cdList = repository.searchConceptualDomain(
keyword, TextSearchType.WildCard);
List<ConceptualDomainModel> cdModelList = new ArrayList<ConceptualDomainModel>();
for (ConceptualDomain cd : cdList) {
if (cd instanceof EnumeratedConceptualDomain) {
cdModelList.add(new ConceptualDomainModel(cd, true));
} else {
cdModelList.add(new ConceptualDomainModel(cd, false));
}
}
return Response.ok(cdModelList).build();
}
项目:semanticMDR
文件:RepositoryService.java
@GET
@Path("/dt")
@Produces(MediaType.APPLICATION_JSON)
public Response listDataTypes(
@CookieParam(AuthenticationService.SID) String sessionID) {
WebUtil.checkUserSession(sessionID);
Repository repository = RepositoryManager.getInstance().getRepository();
List<Datatype> dtList = repository.getDataTypes();
List<DataTypeModel> dtModelList = new ArrayList<DataTypeModel>();
for (Datatype de : dtList) {
dtModelList.add(new DataTypeModel(de));
}
return Response.ok(dtModelList).build();
}
项目:semanticMDR
文件:ObjectClassService.java
@GET
@Path("/parent")
@Produces(MediaType.APPLICATION_JSON)
public Response getParentConcept(
@CookieParam(AuthenticationService.SID) String sessionID,
@PathParam("ocid") String ocID) {
WebUtil.checkUserSession(sessionID);
Repository repository = RepositoryManager.getInstance().getRepository();
ObjectClass objectClass = repository.getObjectClass(ocID);
ObjectClass parent = objectClass.getParentConcept();
if (parent == null) {
return Response.noContent().build();
}
return Response.ok(new ObjectClassModel(parent)).build();
}
项目:semanticMDR
文件:ObjectClassService.java
@GET
@Path("/subconcept")
@Produces(MediaType.APPLICATION_JSON)
public Response getSubConcepts(
@CookieParam(AuthenticationService.SID) String sessionID,
@PathParam("ocid") String ocID) {
WebUtil.checkUserSession(sessionID);
Repository repository = RepositoryManager.getInstance().getRepository();
if (Util.isNull(ocID)) {
throw new WebApplicationException(Status.BAD_REQUEST);
}
ObjectClass objectClass = repository.getObjectClass(ocID);
List<ObjectClassModel> ocModelList = new ArrayList<ObjectClassModel>();
List<ObjectClass> subConceptList = objectClass.getSubConcepts();
for (ObjectClass oc : subConceptList) {
ocModelList.add(new ObjectClassModel(oc));
}
return Response.ok(ocModelList).build();
}
项目:semanticMDR
文件:ObjectClassService.java
@GET
@Path("/dec")
@Produces(MediaType.APPLICATION_JSON)
public Response listDataElementConcepts(
@CookieParam(AuthenticationService.SID) String sessionID,
@PathParam("ocid") String objectClassID,
@QueryParam("limit") @DefaultValue("10") Integer limit,
@QueryParam("offset") @DefaultValue("0") Integer offset) {
WebUtil.checkUserSession(sessionID);
Repository repository = RepositoryManager.getInstance().getRepository();
ObjectClass objectClass = repository.getObjectClass(objectClassID);
List<DataElementConcept> decList = objectClass.getDataElementConcepts(
limit, offset);
List<DataElementConceptModel> decModelList = new ArrayList<DataElementConceptModel>();
for (DataElementConcept dec : decList) {
decModelList.add(new DataElementConceptModel(dec.asMDRResource()));
}
return Response.ok(decModelList).build();
}
项目:semanticMDR
文件:ConceptualDomainService.java
@GET
@Produces(MediaType.APPLICATION_JSON)
public Response getConceptualDomain(
@CookieParam(AuthenticationService.SID) String sessionID,
@PathParam("cid") String cid) {
WebUtil.checkUserSession(sessionID);
Repository repository = RepositoryManager.getInstance().getRepository();
ConceptualDomain cd = repository.getConceptualDomain(cid);
if (cd instanceof EnumeratedConceptualDomain) {
return Response.ok(new ConceptualDomainModel(cd, true)).build();
} else {
return Response.ok(new ConceptualDomainModel(cd, false)).build();
}
}
项目:semanticMDR
文件:ConceptualDomainService.java
@GET
@Path("/vm")
@Produces(MediaType.TEXT_PLAIN)
public Response getNumberOfValueMeanings(
@CookieParam(AuthenticationService.SID) String sessionID,
@PathParam("cid") String conceptualDomainID) {
WebUtil.checkUserSession(sessionID);
Repository repository = RepositoryManager.getInstance().getRepository();
ConceptualDomain cd = repository
.getConceptualDomain(conceptualDomainID);
if (cd instanceof NonEnumeratedConceptualDomain) {
logger.error(
"{} is not EnumeratedConceptualDomain, so no ValueMeaning",
conceptualDomainID);
return Response.serverError().build();
}
EnumeratedConceptualDomain ecd = (EnumeratedConceptualDomain) cd;
int size = ecd.getNumberOfValueMeanings();
return Response.ok(String.valueOf(size)).build();
}