Package com.serotonin.m2m2.vo

Examples of com.serotonin.m2m2.vo.User


public class ReportLaunchServlet extends BaseInfoServlet{
  private static final long serialVersionUID = -1;
 
  @Override
  protected void doGet(HttpServletRequest request, HttpServletResponse response) {
    User user = Common.getUser(request);
    if(user != null) {
      ReportDao dao = new ReportDao();
      ReportVO report = null;
      int id = getIntRequestParameter(request, "reportId", -1);
      if(id != -1)
        report = dao.getReport(id);
      String xid = request.getParameter("reportXid");
      if(xid != null)
        report = dao.getReport(xid);
      if(report != null && (user.getId() == report.getUserId() || user.isAdmin())) {
        ReportJob.scheduleReportJob(report);
        try {
          response.getWriter().write("Report " + report.getName() + " scheduled");
        } catch(Exception e) {
          response.setStatus(500);
View Full Code Here


    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
        // The only place that should be calling this servlet is the report chart, generated by a Freemarker
        // template. The ReportChartCreator that controlled the generation put the generated image content into the
        // user object, so all i need to do is write that content to the response object.
        User user = Common.getUser(request);
        if (user != null) {
            @SuppressWarnings("unchecked")
            Map<String, byte[]> imageData = (Map<String, byte[]>) user.getAttribute(IMAGE_DATA_KEY);
            if (imageData != null) {
                String path = request.getPathInfo();

                // Path will be of the format "/<chartName>", so we need to ignore the first character.
                byte[] data = imageData.get(path.substring(1));
View Full Code Here

    }

    //Helper for JSP Page
    public String getUsername(){
      UserDao userDao = new UserDao();
      User reportUser = userDao.getUser(this.userId);
        if(reportUser != null)
          return reportUser.getUsername();
        else
          return Common.translate("reports.validate.userDNE");
    }
View Full Code Here

            response.addContextualMessage("previousPeriodCount", "reports.validate.periodCountLessThan1");
        if (pastPeriodCount < 1)
            response.addContextualMessage("pastPeriodCount", "reports.validate.periodCountLessThan1");
       
        UserDao dao = new UserDao();
        User user = dao.getUser(userId);
        if(user == null){
            response.addContextualMessage("userId", "reports.validate.userDNE");
        }
       
        File t = new File(Common.MA_HOME + ModuleRegistry.getModule("reports").getDirectoryPath() + "/web/ftl/" + template);
        if(!t.isFile())
          response.addContextualMessage("template", "reports.validate.template");
       
        DataPointDao dataPointDao = new DataPointDao();
        for (ReportPointVO point : points) {
          DataPointVO vo  = dataPointDao.getDataPoint(point.getPointId());
          String pointXid = "unknown";
          if(vo != null){
            pointXid = vo.getXid();
              try{
                Permissions.ensureDataPointReadPermission(user, dataPointDao.getDataPoint(point.getPointId()));
              }catch(PermissionException e){
               
                response.addContextualMessage("points", "reports.vaildate.pointDNE");
              }
          }else{
            response.addContextualMessage("points", "reports.validate.pointPermissions",user.getUsername(), pointXid);
          }
           
            try {
                if (!StringUtils.isBlank(point.getColour()))
                    ColorUtils.toColor(point.getColour());
View Full Code Here

            throws Exception {
        int instanceId = Integer.parseInt(request.getParameter("instanceId"));
        ReportDao reportDao = new ReportDao();
        ReportInstance instance = reportDao.getReportInstance(instanceId);

        User user = Common.getUser(request);
        ReportCommon.ensureReportInstancePermission(user, instance);

        ReportChartCreator creator = new ReportChartCreator(ControllerUtils.getTranslations(request),
                user.getTimeZoneInstance());
        creator.createContent(instance, reportDao, null, false);

        Map<String, byte[]> imageData = new HashMap<String, byte[]>();
        imageData.put(creator.getChartName(), creator.getImageData());
        for (ReportChartCreator.PointStatistics pointStatistics : creator.getPointStatistics())
            imageData.put(pointStatistics.getChartName(), pointStatistics.getImageData());
        user.setAttribute(ReportChartServlet.IMAGE_DATA_KEY, imageData);

        return new ReportChartView(creator.getHtml());
    }
View Full Code Here

    public static void queueReport(ReportVO report) {
        LOG.debug("Queuing report with id " + report.getId());

        // Verify that the user is not disabled.
        User user = new UserDao().getUser(report.getUserId());
        if (user.isDisabled())
            return;

        // User is ok. Continue...
        ReportWorkItem item = new ReportWorkItem();
View Full Code Here

        templateFile = template.getTemplate();
        includeEvents = template.getIncludeEvents();
        includeUserComments = template.isIncludeUserComments();

        UserDao userDao = new UserDao();
        User reportUser = userDao.getUser(userId);
        if(reportUser != null)
          username = reportUser.getUsername();
        else
          username = Common.translate("reports.validate.userDNE");
       
        if (template.getDateRangeType() == ReportVO.DATE_RANGE_TYPE_RELATIVE) {
            if (template.getRelativeDateType() == ReportVO.RELATIVE_DATE_TYPE_PREVIOUS) {
View Full Code Here

public class GraphicalViewEditHandler implements UrlHandler {
    @Override
    public View handleRequest(HttpServletRequest request, HttpServletResponse response, Map<String, Object> model)
            throws Exception {
        GraphicalView view;
        User user = Common.getUser(request);

        // Fresh hit. Get the id.
        String viewIdStr = request.getParameter("viewId");
        if (viewIdStr != null) {
            // An existing view.
            view = new GraphicalViewDao().getView(Integer.parseInt(viewIdStr));
            if (view == null)
                // Doesn't exist. Redirect back to the views page.
                return new RedirectView("/views.shtm");

            GraphicalViewsCommon.ensureViewEditPermission(user, view);

            if ("true".equals(request.getParameter("copy"))) {
                // Make a copy
                GraphicalView copy = new GraphicalView();
                copy.setId(Common.NEW_ID);
                copy.setUserId(user.getId());
                copy.setXid(new GraphicalViewDao().generateUniqueXid());
                copy.setName(StringUtils.abbreviate(TranslatableMessage.translate(
                        ControllerUtils.getTranslations(request), "common.copyPrefix", view.getName()), 100));
                copy.setBackgroundFilename(GraphicalViewsCommon.copyImage(view.getBackgroundFilename()));
                for (ViewComponent vc : view.getViewComponents())
                    copy.addViewComponent(vc);

                view = copy;
            }
        }
        else {
            // A new view.
            view = new GraphicalView();
            view.setId(Common.NEW_ID);
            view.setUserId(user.getId());
            view.setXid(new GraphicalViewDao().generateUniqueXid());
        }

        GraphicalViewsCommon.setUserEditView(user, view);
        view.validateViewComponents(false);
View Full Code Here

     * This method is used before the view is displayed in order to validate: - that the given user is allowed to access
     * points that back any components - that the points that back components still have valid data types for the
     * components that render them
     */
    public void validateViewComponents(boolean makeReadOnly) {
        User owner = new UserDao().getUser(userId);
        for (ViewComponent viewComponent : viewComponents)
            viewComponent.validateDataPoint(owner, makeReadOnly);
    }
View Full Code Here

    public void jsonRead(JsonReader reader, JsonObject jsonObject) throws JsonException {
        if (isNew()) {
            String username = jsonObject.getString("user");
            if (StringUtils.isBlank(username))
                throw new TranslatableJsonException("emport.error.missingValue", "user");
            User user = new UserDao().getUser(username);
            if (user == null)
                throw new TranslatableJsonException("emport.error.missingUser", username);
            userId = user.getId();
        }

        JsonArray components = jsonObject.getJsonArray("viewComponents");
        if (components != null) {
            viewComponents.clear();
View Full Code Here

TOP

Related Classes of com.serotonin.m2m2.vo.User

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.