示例#1
0
 @POST
 @Path("/profile")
 @Consumes(MediaType.APPLICATION_JSON)
 @Produces(MediaType.APPLICATION_JSON)
 public Response addProfile(Profile profile) {
   // http://localhost:8080/CitoServer/rest/profileService/add
   if (profile.getId() > 0) {
     dao.updateProfile(mapper.mapToDb(profile));
   } else {
     int id = dao.addProfile(mapper.mapToDb(profile));
     profile.setId(id);
   }
   ReturnId returnId = new ReturnId(profile.getId());
   return Response.status(200).entity(returnId).build();
 }
  private Profile getActionAuditOwner(
      Map<String, Profile> actionOwnersCache, UGCAudit currentAudit) {
    Profile p = actionOwnersCache.get(currentAudit.getProfileId());
    if (p == null) {
      Profile currentProfile =
          this.profileRepository.findOne(new ObjectId(currentAudit.getProfileId()));
      p = new Profile();
      if (currentProfile != null) {
        p.setUserName(currentProfile.getUserName());
        p.setTenantName(currentProfile.getTenantName());
        p.setEmail(currentProfile.getEmail());
        p.setId(currentProfile.getId());
      }
      actionOwnersCache.put(currentAudit.getProfileId(), p);
    }

    return p;
  }