Search in sources :

Example 1 with After

use of org.aspectj.lang.annotation.After in project entando-core by entando.

the class PreviewWidgetExecutorAspect method checkContentPreview.

@After("execution(* org.entando.entando.aps.system.services.controller.executor.WidgetExecutorService.service(..)) && args(reqCtx)")
public void checkContentPreview(RequestContext reqCtx) {
    HttpServletRequest request = reqCtx.getRequest();
    String contentOnSessionMarker = (String) request.getAttribute("contentOnSessionMarker");
    if (null == contentOnSessionMarker || contentOnSessionMarker.trim().length() == 0) {
        contentOnSessionMarker = request.getParameter("contentOnSessionMarker");
    }
    if (null == contentOnSessionMarker) {
        return;
    }
    Content contentOnSession = (Content) request.getSession().getAttribute(ContentActionConstants.SESSION_PARAM_NAME_CURRENT_CONTENT_PREXIX + contentOnSessionMarker);
    if (null == contentOnSession) {
        return;
    }
    try {
        IPage currentPage = (IPage) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_PAGE);
        Widget[] widgets = currentPage.getWidgets();
        for (int frame = 0; frame < widgets.length; frame++) {
            Widget widget = widgets[frame];
            if (widget != null && "viewerConfig".equals(widget.getType().getAction())) {
                if ((currentPage.getCode().equals(contentOnSession.getViewPage()) && (widget.getConfig() == null || widget.getConfig().size() == 0)) || (widget.getConfig() != null && widget.getConfig().get("contentId") != null && widget.getConfig().get("contentId").equals(contentOnSession.getId()))) {
                    reqCtx.addExtraParam(SystemConstants.EXTRAPAR_CURRENT_WIDGET, widget);
                    reqCtx.addExtraParam(SystemConstants.EXTRAPAR_CURRENT_FRAME, new Integer(frame));
                    String output = super.extractJspOutput(reqCtx, CONTENT_VIEWER_JSP);
                    String[] widgetOutput = (String[]) reqCtx.getExtraParam("ShowletOutput");
                    widgetOutput[frame] = output;
                    return;
                }
            }
        }
    } catch (Throwable t) {
        String msg = "Error detected while include content preview";
        _logger.error(msg, t);
        throw new RuntimeException(msg, t);
    }
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) IPage(com.agiletec.aps.system.services.page.IPage) Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content) Widget(com.agiletec.aps.system.services.page.Widget) After(org.aspectj.lang.annotation.After)

Example 2 with After

use of org.aspectj.lang.annotation.After in project incubator-pulsar by apache.

the class ZooKeeperServerAspect method zkServerConstructor.

@After("zkServerConstructorPointCut()")
public void zkServerConstructor(JoinPoint joinPoint) throws Throwable {
    // ZooKeeperServer instance was created
    ZooKeeperServer zkServer = (ZooKeeperServer) joinPoint.getThis();
    synchronized (ZooKeeperServerAspect.class) {
        if (metricsRegistered) {
            // We can only register the metrics a single time for the process
            return;
        }
        metricsRegistered = true;
    }
    Gauge.build().name("zookeeper_server_znode_count").help("Number of z-nodes stored").create().setChild(new Gauge.Child() {

        @Override
        public double get() {
            return zkServer.getZKDatabase().getNodeCount();
        }
    }).register();
    Gauge.build().name("zookeeper_server_data_size_bytes").help("Size of all of z-nodes stored (bytes)").create().setChild(new Gauge.Child() {

        @Override
        public double get() {
            return zkServer.getZKDatabase().getDataTree().approximateDataSize();
        }
    }).register();
    Gauge.build().name("zookeeper_server_connections").help("Number of currently opened connections").create().setChild(new Gauge.Child() {

        @Override
        public double get() {
            return zkServer.serverStats().getNumAliveClientConnections();
        }
    }).register();
    Gauge.build().name("zookeeper_server_watches_count").help("Number of watches").create().setChild(new Gauge.Child() {

        @Override
        public double get() {
            return zkServer.getZKDatabase().getDataTree().getWatchCount();
        }
    }).register();
    Gauge.build().name("zookeeper_server_ephemerals_count").help("Number of ephemerals z-nodes").create().setChild(new Gauge.Child() {

        @Override
        public double get() {
            return zkServer.getZKDatabase().getDataTree().getEphemeralsCount();
        }
    }).register();
}
Also used : ZooKeeperServer(org.apache.zookeeper.server.ZooKeeperServer) After(org.aspectj.lang.annotation.After)

Example 3 with After

use of org.aspectj.lang.annotation.After in project trainning by fernandotomasio.

the class MatriculasLoggerAdvice method logCreateMatricula.

@After("create()")
public void logCreateMatricula(JoinPoint joinPoint) {
    MatriculaDTO[] matriculas = (MatriculaDTO[]) joinPoint.getArgs()[0];
    if (matriculas != null && matriculas.length > 0) {
        try {
            LogDTO log = new LogDTO();
            log.setDataCriacao(new Date());
            log.setUser(getUser());
            for (MatriculaDTO matriculaDTO : matriculas) {
                String texto = "CRIAÇÃO DE MATRÍCULA " + getDetails(matriculaDTO);
                log.setTexto(texto);
                logger.create(log);
            }
        } catch (DAOException ex) {
            Logger.getLogger(MatriculasLoggerAdvice.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}
Also used : MatriculaDTO(com.tomasio.projects.trainning.dto.MatriculaDTO) DAOException(com.tomasio.projects.trainning.exception.DAOException) LogDTO(com.tomasio.projects.trainning.dto.LogDTO) Date(java.util.Date) After(org.aspectj.lang.annotation.After)

Example 4 with After

use of org.aspectj.lang.annotation.After in project trainning by fernandotomasio.

the class TrainningServiceLoggerAdvice method logUpdateCurso.

@After("update()")
public void logUpdateCurso(JoinPoint joinPoint) {
    CursoDAO dao = factory.getCursoDAO();
    CursoDTO curso = (CursoDTO) joinPoint.getArgs()[0];
    if (curso != null) {
        try {
            curso = dao.find(curso.getId()).createDTO();
            LogDTO log = new LogDTO();
            log.setDataCriacao(new Date());
            log.setUser(getUser());
            log.setObjectId(curso.getObjectId());
            String texto = "ATUALIZADO O CURSO " + getDetails(curso);
            log.setTexto(texto);
            logger.create(log);
        } catch (DAOException ex) {
            Logger.getLogger(TrainningServiceLoggerAdvice.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) LogDTO(com.tomasio.projects.trainning.dto.LogDTO) CursoDTO(com.tomasio.projects.trainning.dto.CursoDTO) CursoDAO(com.tomasio.projects.trainning.dao.CursoDAO) Date(java.util.Date) After(org.aspectj.lang.annotation.After)

Example 5 with After

use of org.aspectj.lang.annotation.After in project PhotoNoter by yydcdut.

the class PermissionAspect method afterPermissionRequestBack.

@After("execution(* android.support.v4.app.FragmentActivity.onRequestPermissionsResult(..))")
public void afterPermissionRequestBack(JoinPoint joinPoint) {
    YLog.i(TAG, "afterPermissionRequestBack");
    Object[] objects = joinPoint.getArgs();
    Object object = joinPoint.getTarget();
    if (objects.length >= 1 && objects[0] instanceof Integer && object != null && object instanceof IView && ((IView) object).getPresenter() != null) {
        int requestCode = (int) objects[0];
        invokeMethod(((IView) object).getPresenter(), requestCode);
    } else {
        YLog.i(TAG, "afterPermissionRequestBack --> bad");
    }
}
Also used : IView(com.yydcdut.note.views.IView) JoinPoint(org.aspectj.lang.JoinPoint) ProceedingJoinPoint(org.aspectj.lang.ProceedingJoinPoint) After(org.aspectj.lang.annotation.After)

Aggregations

After (org.aspectj.lang.annotation.After)11 LogDTO (com.tomasio.projects.trainning.dto.LogDTO)3 DAOException (com.tomasio.projects.trainning.exception.DAOException)3 Date (java.util.Date)3 CursoDAO (com.tomasio.projects.trainning.dao.CursoDAO)2 IView (com.yydcdut.note.views.IView)2 JoinPoint (org.aspectj.lang.JoinPoint)2 ProceedingJoinPoint (org.aspectj.lang.ProceedingJoinPoint)2 IPage (com.agiletec.aps.system.services.page.IPage)1 Widget (com.agiletec.aps.system.services.page.Widget)1 Content (com.agiletec.plugins.jacms.aps.system.services.content.model.Content)1 Item (com.ctrip.framework.apollo.biz.entity.Item)1 BadRequestException (com.ctrip.framework.apollo.common.exception.BadRequestException)1 JMethod (com.google.gwt.dev.jjs.ast.JMethod)1 JProgram (com.google.gwt.dev.jjs.ast.JProgram)1 ControlFlowAnalyzer (com.google.gwt.dev.jjs.impl.ControlFlowAnalyzer)1 CursoDTO (com.tomasio.projects.trainning.dto.CursoDTO)1 IndicacaoDTO (com.tomasio.projects.trainning.dto.IndicacaoDTO)1 MatriculaDTO (com.tomasio.projects.trainning.dto.MatriculaDTO)1 Pattern (java.util.regex.Pattern)1