本文整理汇总了Java中com.yammer.metrics.annotation.Timed类的典型用法代码示例。如果您正苦于以下问题:Java Timed类的具体用法?Java Timed怎么用?Java Timed使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Timed类属于com.yammer.metrics.annotation包,在下文中一共展示了Timed类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: update
import com.yammer.metrics.annotation.Timed; //导入依赖的package包/类
@PUT
@Timed @Path("{id}")
@UnitOfWork
public Response update(
@SessionAuth(required = { Priv.ADMIN }) SessionFilteredAuthorization auths,
@SessionUser User user, @SessionCurProj Project currentProject,
@PathParam("id") Long id, @Valid UserProject userProject) {
Project p = pd.findById(currentProject.getId());
if (p == null)
throw new WebApplicationException(Response.Status.FORBIDDEN);
User u = this.ud.findById(userProject.getIdForUser());
userProject.setUser(u);
userProject.setProject(p);
UserProject newUserProject = upd.save(userProject);
//
URI uri = UriBuilder.fromResource(UserProjectResource.class).build(
newUserProject.getId());
log.info("the response uri will be " + uri);
sro.reloadSessionForUser(u);
return Response.created(uri).build();
}
示例2: delete
import com.yammer.metrics.annotation.Timed; //导入依赖的package包/类
@DELETE
@Timed
@Path("{id}")
@Consumes(MediaType.TEXT_PLAIN)
@UnitOfWork
public Response delete(
@SessionAuth(required = { Priv.ADMIN }) SessionFilteredAuthorization auths,
@SessionUser User user, @SessionCurProj Project currentProject,
@PathParam("id") Long id) {
Project p = pd.findById(currentProject.getId());
UserProject deleteableUserProject = upd.findById(id);
if(p.getId() != deleteableUserProject.getProject().getId()) throw new WebApplicationException(Response.Status.FORBIDDEN);
upd.delete(id);
sro.reloadSessionForUser(deleteableUserProject.getUser());
return Response.ok().build();
}
示例3: update
import com.yammer.metrics.annotation.Timed; //导入依赖的package包/类
@PUT
@Timed
@Path("{id}")
@UnitOfWork
public Response update(
@SessionAuth(required = { Priv.ADMIN }) SessionFilteredAuthorization auths,
@SessionUser User user, @SessionCurProj Project currentProject,
@PathParam("id") Long id, @Valid Project project) {
Project p = projectDAO.findById(id);
if (p == null)
throw new WebApplicationException(Response.Status.FORBIDDEN);
if (!p.getId().equals(project.getId()))
throw new WebApplicationException(Response.Status.FORBIDDEN);
if(!p.getPrimaryAdmin().getId().equals(user.getId())) throw new WebApplicationException(Response.Status.FORBIDDEN);
project.setPrimaryAdmin(user);
Project newProject = projectDAO.save(project);
//
URI uri = UriBuilder.fromResource(ProjectResource.class).build(
newProject.getId());
log.info("the response uri will be " + uri);
return Response.created(uri).build();
}
示例4: accept
import com.yammer.metrics.annotation.Timed; //导入依赖的package包/类
@GET
@Timed
@UnitOfWork
@Path("accept")
public Response accept( @QueryParam("code") String code) {
log.info("redeeming invite code "+code);
Invite i = this.inviteDAO.findByCode(code);
Map<String,String> m = new HashMap<String,String>();
m.put("email",i.getEmail());
m.put("projectName", i.getProject().getName());
m.put("projectDesc", i.getProject().getName());
m.put("fromUser",i.getInviter().getUsername());
m.put("fromUserEmail",i.getInviter().getEmail());
return Response.ok(m).build();
}
示例5: joinProject
import com.yammer.metrics.annotation.Timed; //导入依赖的package包/类
@POST
@Timed
@UnitOfWork
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Path("join")
public Response joinProject(@SessionUser User user,JoinProjectRequest request) {
log.info("GOT an new project "+request);
//TODO setup a permissions sort of things.
String name = request.getSelectedProject();
Project p = this.projectDAO.findByName(name);
if(p != null) {
UserProject up = new UserProject();
User u = this.userDAO.findById(user.getId());
up.setProject(p);
up.setUser(u);
this.upDAO.save(up);
} else {
}
return Response.ok().build();
}
示例6: getNextEvent
import com.yammer.metrics.annotation.Timed; //导入依赖的package包/类
@GET
@Timed
@Produces(MediaType.APPLICATION_JSON)
@UnitOfWork
@Path("nextEvent")
public NextEventRecord getNextEvent(@SessionAuth(required={Priv.CATEGORIZE}) SessionFilteredAuthorization auths,@SessionCurProj Project currentProject,@SessionUser User user, @QueryParam("lastEvent") String lastEventIdStr) {
Long lastEventId = null;
try {
lastEventId = Long.parseLong(lastEventIdStr);
} catch (NumberFormatException e) {
// stupid API ignore this exception
}
NextEventRecord ner = this.ds.makeNextEventRecord(user,currentProject,lastEventId);
if(ner.getImageEvent() != null) {
for(ImageRecord ir: ner.getImageEvent().getImageRecords()) {
ir.getDatetime();
}
ImageEvent upie = initializeAndUnproxy(ner.getImageEvent());
ner.setImageEvent(upie);
}
return ner;
}
示例7: add
import com.yammer.metrics.annotation.Timed; //导入依赖的package包/类
@POST
@Timed
@UnitOfWork
public Response add(
@SessionAuth(required = { Priv.ADMIN }) SessionFilteredAuthorization auths,
@SessionUser User user, @SessionCurProj Project currentProject,
@Valid Camera camera) {
log.info("Ok we have the following session user " + user);
Project p = pd.findById(currentProject.getId());
if (p == null)
throw new WebApplicationException(Response.Status.FORBIDDEN);
camera.setProject(p);
Camera newCamera = cd.save(camera);
URI uri = UriBuilder.fromResource(CameraResource.class).build(
newCamera.getId());
log.info("the response uri will be " + uri);
return Response.created(uri).build();
}
示例8: update
import com.yammer.metrics.annotation.Timed; //导入依赖的package包/类
@PUT
@Timed
@Path("{id}")
@UnitOfWork
public Response update(
@SessionAuth(required = { Priv.ADMIN }) SessionFilteredAuthorization auths,
@SessionUser User user, @SessionCurProj Project currentProject,
@PathParam("id") Long id, @Valid Camera camera) {
Project p = pd.findById(currentProject.getId());
if (p == null)
throw new WebApplicationException(Response.Status.FORBIDDEN);
if (!p.getId().equals(camera.getProject().getId()))
throw new WebApplicationException(Response.Status.FORBIDDEN);
Camera newCamera = cd.save(camera);
//
URI uri = UriBuilder.fromResource(CameraResource.class).build(
newCamera.getId());
log.info("the response uri will be " + uri);
return Response.created(uri).build();
}
示例9: delete
import com.yammer.metrics.annotation.Timed; //导入依赖的package包/类
@DELETE
@Timed
@Path("{id}")
@Consumes(MediaType.TEXT_PLAIN)
@UnitOfWork
public Response delete(
@SessionAuth(required = { Priv.ADMIN }) SessionFilteredAuthorization auths,
@SessionUser User user, @SessionCurProj Project currentProject,
@PathParam("id") Long id) {
Project p = pd.findById(currentProject.getId());
Camera deleteableCamera = cd.findById(id);
if(p.getId() != deleteableCamera.getProject().getId()) throw new WebApplicationException(Response.Status.FORBIDDEN);
cd.delete(id);
return Response.ok().build();
}
示例10: lookupToo
import com.yammer.metrics.annotation.Timed; //导入依赖的package包/类
@GET
@Timed
@Path("lookup")
@UnitOfWork
public List<UserTO> lookupToo(@SessionUser User user, @QueryParam("text") String snippet,@QueryParam("p") String projectIdStr) {
if(snippet == null) throw new NotFoundException();
if(snippet.length() < 3) throw new NotFoundException();
Project project = null;
try {
Long projectId = null;
projectId = Long.parseLong(projectIdStr);
project = this.projectDAO.findById(projectId);
} catch(NumberFormatException nfe) {}
User u = this.ud.findByPortionOfEmailUsername(snippet);
if(u == null) return null;
// now remove it, if it's already in existence.
List<UserProject> current= this.upDAO.findByUserIdProjectId(u, project);
if(current.size() > 0) throw new NotFoundException();
ArrayList<UserTO> l = new ArrayList<UserTO>();
l.add(new UserTO(u));
return l;
}
示例11: userupdate
import com.yammer.metrics.annotation.Timed; //导入依赖的package包/类
@POST
@Timed
@Path("userupdate")
@UnitOfWork
public Response userupdate(@SessionUser User user, @Context HttpServletRequest request, UserUpdate updatedCurUser) {
int userId = user.getId();
User editUser = this.ud.findById(userId);
// email -- this should require a REVERIFICATION
this.ud.save(editUser);
clearSession(request);
loadAssociatedAndSetSessionWith(request, editUser);
loadStartingProject(request,editUser);
// there is an implicit SAVE on editUser
return Response.status(Response.Status.OK).build();
}
示例12: lostpw
import com.yammer.metrics.annotation.Timed; //导入依赖的package包/类
@POST
@Timed
@Path("lostpw")
@UnitOfWork
public Response lostpw(String resetemail) {
log.info("starting reset password on "+resetemail);
// now create and send via email a token which will return to a page on which a new PW can be chosen.
// that page should simple reset the password IF the token is valid and matches the email.
// token should live for a fixed amount of time. 10 minutes ?
User p = this.ud.findByEmail(resetemail);
if(p != null) {
String token = tokendao.createToken(p);
try {
emailService.sendPasswordResetEmail(p, token);
} catch (MessagingException e) {
}
}
// return OK regardless so that we don't "leak" data about membership.
return Response.status(Response.Status.OK).build();
}
示例13: verify
import com.yammer.metrics.annotation.Timed; //导入依赖的package包/类
@POST
@Timed
@Path("verify")
@UnitOfWork
public Response verify(@Context HttpServletRequest request,VerifyRequest req) {
String code = req.getVerifyCode();
User p = ud.findByVerifyCode(code);
if(p == null) {
return Response.status(Response.Status.NOT_FOUND).build();
}
p.setVerified(true);
try {
this.emailService.sendUsANotification(p);
} catch (MessagingException e) {
// do nothing here
}
if(autoLoginOnVerify) {
loadAssociatedAndSetSessionWith(request,p);
loadStartingProject(request,p);
}
VerifyResponse vr = new VerifyResponse(p);
return Response.ok(vr, MediaType.APPLICATION_JSON).build();
}
示例14: getEventData
import com.yammer.metrics.annotation.Timed; //导入依赖的package包/类
@GET
@Timed
@UnitOfWork
@Path("event/{eventId}")
public Response getEventData(@SessionAuth(required={Priv.REPORT}) SessionFilteredAuthorization auths,@SessionUser User user, @SessionCurProj Project currentProject, @PathParam("eventId") Long eventId) {
if(eventId == null) return Response.status(Status.NOT_FOUND).build();
ImageEvent e = eventDAO.findById(eventId);
if(e == null) return Response.status(Status.NOT_FOUND).build();
// load data about categorization
List<SpeciesCount> lsc = this.rd.findCategorizationData(e);
// load flagging data
Integer reviewCount = this.reviewDao.getReviewFlagCount(e,user);
Map<String, Integer> m = new HashMap<String,Integer>();
// load images data included "good" images data
for(ImageRecord ir :e.getImageRecords()) {
Integer good = this.goodDao.getGoodFlagCount(ir,user);
m.put(ir.getId(),good);
}
CurrentEventInfo cei = new CurrentEventInfo(lsc,reviewCount,m);
return Response.ok(cei).build();
}
示例15: getFieldMappings
import com.yammer.metrics.annotation.Timed; //导入依赖的package包/类
@Override
@Timed
public TableFieldMapping getFieldMappings(String table) throws FoxtrotException {
table = ElasticsearchUtils.getValidTableName(table);
if (!tableMetadataManager.exists(table)) {
throw FoxtrotExceptions.createTableMissingException(table);
}
try {
ElasticsearchMappingParser mappingParser = new ElasticsearchMappingParser(mapper);
Set<FieldTypeMapping> mappings = new HashSet<>();
GetMappingsResponse mappingsResponse = connection.getClient().admin()
.indices().prepareGetMappings(ElasticsearchUtils.getIndices(table)).execute().actionGet();
for (ObjectCursor<String> index : mappingsResponse.getMappings().keys()) {
MappingMetaData mappingData = mappingsResponse.mappings().get(index.value).get(ElasticsearchUtils.DOCUMENT_TYPE_NAME);
mappings.addAll(mappingParser.getFieldMappings(mappingData));
}
return new TableFieldMapping(table, mappings);
} catch (IOException e) {
throw FoxtrotExceptions.createExecutionException(table, e);
}
}