Examples of ActionResult


Examples of org.apache.hadoop.hbase.protobuf.generated.ClientProtos.ActionResult

    long before = EnvironmentEdgeManager.currentTimeMillis();
    boolean batchContainsPuts = false, batchContainsDelete = false;
    try {
      ActionResult.Builder resultBuilder = ActionResult.newBuilder();
      resultBuilder.setValue(ClientProtos.Result.newBuilder().build());
      ActionResult result = resultBuilder.build();
      int i = 0;
      for (MutationProto m : mutations) {
        Mutation mutation;
        if (m.getMutateType() == MutationType.PUT) {
          mutation = ProtobufUtil.toPut(m, cells);
          batchContainsPuts = true;
        } else {
          mutation = ProtobufUtil.toDelete(m, cells);
          batchContainsDelete = true;
        }
        mArray[i++] = mutation;
        builder.addResult(result);
      }

      requestCount.add(mutations.size());
      if (!region.getRegionInfo().isMetaTable()) {
        cacheFlusher.reclaimMemStoreMemory();
      }

      OperationStatus codes[] = region.batchMutate(mArray, isReplay);
      for (i = 0; i < codes.length; i++) {
        switch (codes[i].getOperationStatusCode()) {
          case BAD_FAMILY:
            result = ResponseConverter.buildActionResult(
                new NoSuchColumnFamilyException(codes[i].getExceptionMsg()));
            builder.setResult(i, result);
            break;

          case SANITY_CHECK_FAILURE:
            result = ResponseConverter.buildActionResult(
                new FailedSanityCheckException(codes[i].getExceptionMsg()));
            builder.setResult(i, result);
            break;

          default:
            result = ResponseConverter.buildActionResult(
                new DoNotRetryIOException(codes[i].getExceptionMsg()));
            builder.setResult(i, result);
            break;

          case SUCCESS:
            break;
        }
        if (isReplay && codes[i].getOperationStatusCode() != OperationStatusCode.SUCCESS) {
          // in replay mode, we only need to catpure the first error because we will retry the whole
          // batch when an error happens
          break;
        }
      }
    } catch (IOException ie) {
      ActionResult result = ResponseConverter.buildActionResult(ie);
      for (int i = 0; i < mutations.size(); i++) {
        builder.setResult(i, result);
        if (isReplay) {
          // in replay mode, we only need to catpure the first error because we will retry the whole
          // batch when an error happens
View Full Code Here

Examples of org.apache.hadoop.hbase.protobuf.generated.ClientProtos.ActionResult

    long before = EnvironmentEdgeManager.currentTimeMillis();
    boolean batchContainsPuts = false, batchContainsDelete = false;
    try {
      ActionResult.Builder resultBuilder = ActionResult.newBuilder();
      resultBuilder.setValue(ClientProtos.Result.newBuilder().build());
      ActionResult result = resultBuilder.build();
      int i = 0;
      for (MutationProto m : mutations) {
        Mutation mutation;
        if (m.getMutateType() == MutationType.PUT) {
          mutation = ProtobufUtil.toPut(m, cells);
          batchContainsPuts = true;
        } else {
          mutation = ProtobufUtil.toDelete(m, cells);
          batchContainsDelete = true;
        }
        mutationsWithLocks[i++] = new Pair<Mutation, Integer>(mutation, null);
        builder.addResult(result);
      }

      requestCount.add(mutations.size());
      if (!region.getRegionInfo().isMetaTable()) {
        cacheFlusher.reclaimMemStoreMemory();
      }

      OperationStatus codes[] = region.batchMutate(mutationsWithLocks);
      for (i = 0; i < codes.length; i++) {
        switch (codes[i].getOperationStatusCode()) {
          case BAD_FAMILY:
            result = ResponseConverter.buildActionResult(
                new NoSuchColumnFamilyException(codes[i].getExceptionMsg()));
            builder.setResult(i, result);
            break;

          case SANITY_CHECK_FAILURE:
            result = ResponseConverter.buildActionResult(
                new FailedSanityCheckException(codes[i].getExceptionMsg()));
            builder.setResult(i, result);
            break;

          default:
            result = ResponseConverter.buildActionResult(
                new DoNotRetryIOException(codes[i].getExceptionMsg()));
            builder.setResult(i, result);
            break;

          case SUCCESS:
            break;
        }
      }
    } catch (IOException ie) {
      ActionResult result = ResponseConverter.buildActionResult(ie);
      for (int i = 0; i < mutations.size(); i++) {
        builder.setResult(i, result);
      }
    }
    long after = EnvironmentEdgeManager.currentTimeMillis();
View Full Code Here

Examples of org.apache.hadoop.hbase.protobuf.generated.ClientProtos.ActionResult

      final CellScanner cells)
  throws IOException {
    List<Object> results = new ArrayList<Object>();
    List<ActionResult> resultList = proto.getResultList();
    for (int i = 0, n = resultList.size(); i < n; i++) {
      ActionResult result = resultList.get(i);
      if (result.hasException()) {
        results.add(ProtobufUtil.toException(result.getException()));
      } else if (result.hasValue()) {
        ClientProtos.Result value = result.getValue();
        results.add(ProtobufUtil.toResult(value, cells));
      } else {
        results.add(new Result());
      }
    }
View Full Code Here

Examples of org.dspace.xmlworkflow.state.actions.ActionResult

        String submitButton = Util.getSubmitButton(request, "submit_cancel");

        //Check if our user has pressed cancel
        if(submitButton.equals("submit_cancel")){
            //Send us back to the submissions page
            return new ActionResult(ActionResult.TYPE.TYPE_CANCEL);

        }else
        if(submitButton.equals("submit_search")){
            //Perform the search
            String query = request.getParameter("query");
            int page = Util.getIntParameter(request, "result-page");
            if(page == -1){
                page = 0;
            }

            int resultCount = EPerson.searchResultCount(c, query);
            EPerson[] epeople = EPerson.search(c, query, page*RESULTS_PER_PAGE, RESULTS_PER_PAGE);


            request.setAttribute("eperson-result-count", resultCount);
            request.setAttribute("eperson-results", epeople);
            request.setAttribute("result-page", page);
            request.setAttribute("page", SEARCH_RESULTS_PAGE);
            return new ActionResult(ActionResult.TYPE.TYPE_PAGE, SEARCH_RESULTS_PAGE);
        }else
        if(submitButton.startsWith("submit_select_reviewer_")){
            //Retrieve the identifier of the eperson which will do the reviewing
            int reviewerId = Integer.parseInt(submitButton.substring(submitButton.lastIndexOf("_") + 1));
            EPerson reviewer = EPerson.find(c, reviewerId);
            //We have a reviewer, assign him, the workflowitemrole will be translated into a task in the autoassign
            WorkflowItemRole workflowItemRole = WorkflowItemRole.create(c);
            workflowItemRole.setEPerson(reviewer);
            workflowItemRole.setRoleId(getRoleId());
            workflowItemRole.setWorkflowItemId(wfi.getID());
            workflowItemRole.update();
            return new ActionResult(ActionResult.TYPE.TYPE_OUTCOME, ActionResult.OUTCOME_COMPLETE);
        }

        //There are only 2 active buttons on this page, so if anything else happens just return an error
        return new ActionResult(ActionResult.TYPE.TYPE_ERROR);
    }
View Full Code Here

Examples of org.jahia.bin.ActionResult

        convertedFileNode.setProperty("convertedDocFormat", returnedMimeType);
        convertedFileNode.setProperty("conversionSucceeded", conversionSucceeded);

        session.save();
        }
        return new ActionResult(HttpServletResponse.SC_OK, null, new JSONObject());
    }
View Full Code Here

Examples of org.jahia.bin.ActionResult

        Map<String,Object> bindings = new HashMap<String,Object>();
        bindings.put("newUser",user);
        if (mailService.isEnabled()) {
            mailService.sendMessageWithTemplate(templatePath,bindings,to,from,cc,bcc,resource.getLocale(),"Jahia User Registration");
        }
        return new ActionResult(HttpServletResponse.SC_ACCEPTED,parameters.get("userredirectpage").get(0), new JSONObject());
    }
View Full Code Here

Examples of org.jahia.bin.ActionResult

        String passwd = req.getParameter("password").trim();
        JSONObject json = new JSONObject();

        if (!resource.getNode().hasPermission("jcr:write_default") || !resource.getNode().isNodeType("jnt:user")) {
            return new ActionResult(HttpServletResponse.SC_FORBIDDEN, null, null);
        }

        if ("".equals(passwd)) {
            String userMessage = JahiaResourceBundle.getJahiaInternalResource("org.jahia.admin.userMessage.specifyPassword.label", renderContext.getUILocale());
            json.put("errorMessage", userMessage);
        } else {
            String passwdConfirm = req.getParameter("passwordconfirm").trim();
            if (!passwdConfirm.equals(passwd)) {
                String userMessage = JahiaResourceBundle.getJahiaInternalResource("org.jahia.admin.userMessage.passwdNotMatch.label", renderContext.getUILocale());
                json.put("errorMessage",userMessage);
            } else {
                JahiaPasswordPolicyService pwdPolicyService = ServicesRegistry.getInstance().getJahiaPasswordPolicyService();
                JahiaUser user = ServicesRegistry.getInstance().getJahiaUserManagerService().lookupUser(resource.getNode().getName());

                PolicyEnforcementResult evalResult = pwdPolicyService.enforcePolicyOnPasswordChange(user, passwd, true);
                if (!evalResult.isSuccess()) {
                    EngineMessages policyMsgs = evalResult.getEngineMessages();
                    String res = "";
                    for (EngineMessage message : policyMsgs.getMessages()) {
                        res += (message.isResource() ? MessageFormat.format(JahiaResourceBundle.getJahiaInternalResource(message.getKey(), renderContext.getUILocale()), message.getValues()) : message.getKey())+"\n";
                    }
                    json.put("errorMessage", res);
                } else {
                    // change password
                    user.setPassword(passwd);
                    json.put("errorMessage", JahiaResourceBundle.getJahiaInternalResource("org.jahia.admin.userMessage.passwordChanged.label", renderContext.getUILocale()));

                    httpSession.setAttribute(ProcessingContext.SESSION_USER, user);

                    json.put("result", "success");
                }
            }
        }

        return new ActionResult(HttpServletResponse.SC_OK, null, json);
    }
View Full Code Here

Examples of org.jahia.bin.ActionResult

        if (req.getSession().getAttribute("passwordRecoveryAsked") != null) {
            JSONObject json = new JSONObject();
            String message = JahiaResourceBundle.getString("JahiaUserRegistration", "passwordrecovery.mail.alreadysent",
                    resource.getLocale(), "Jahia User Registration");
            json.put("message", message);
            return new ActionResult(HttpServletResponse.SC_OK, null, json);
        }

        JahiaUser user = userManagerService.lookupUser(username);
        if (user == null ) {
            JSONObject json = new JSONObject();
            String message = JahiaResourceBundle.getString("JahiaUserRegistration", "passwordrecovery.username.invalid",
                    resource.getLocale(), "Jahia User Registration");
            json.put("message", message);
            return new ActionResult(SC_OK, null, json);
        }

        String to = user.getProperty("j:email");
        if (to == null || !MailService.isValidEmailAddress(to, false)) {
            JSONObject json = new JSONObject();
            String message = JahiaResourceBundle.getString("JahiaUserRegistration", "passwordrecovery.mail.invalid",
                    resource.getLocale(), "Jahia User Registration");
            json.put("message", message);
            return new ActionResult(SC_OK, null, json);
        }
        String from = SettingsBean.getInstance().getMail_from();

        String authKey = DigestUtils.md5Hex(username + System.currentTimeMillis());
        req.getSession().setAttribute("passwordRecoveryToken", new PasswordToken(authKey, user.getLocalPath()));

        Map<String,Object> bindings = new HashMap<String,Object>();
        bindings.put("link", req.getScheme() + "://" + req.getServerName() + ":" + req.getServerPort() +
                Jahia.getContextPath() + Render.getRenderServletPath() + "/live/"
                + resource.getLocale().getLanguage() + resource.getNode().getPath() + ".html?key=" + authKey);
        bindings.put("user", user);

        mailService.sendMessageWithTemplate(templatePath, bindings, to, from, null, null, resource.getLocale(), "Jahia User Registration");
        req.getSession().setAttribute("passwordRecoveryAsked", true);

        JSONObject json = new JSONObject();
        String message = JahiaResourceBundle.getString("JahiaUserRegistration", "passwordrecovery.mail.sent",
                resource.getLocale(), "Jahia User Registration");
        json.put("message", message);
        return new ActionResult(HttpServletResponse.SC_ACCEPTED, null, json);
    }
View Full Code Here

Examples of org.jahia.bin.ActionResult

                node.setProperty("j:lastVote", values.get(0));
                node.setProperty("j:nbOfVotes",node.getProperty("j:nbOfVotes").getLong()+1);
                node.setProperty("j:sumOfVotes",node.getProperty("j:sumOfVotes").getLong()+ Long.valueOf(values.get(0)));
                session.save();
                try {
                    return new ActionResult(HttpServletResponse.SC_OK, node.getPath(), Render.serializeNodeToJSON(node));
                } catch (IOException e) {
                    e.printStackTrace()//To change body of catch statement use File | Settings | File Templates.
                } catch (JSONException e) {
                    e.printStackTrace()//To change body of catch statement use File | Settings | File Templates.
                }
View Full Code Here

Examples of org.jahia.bin.ActionResult

            bookmark.setProperty("date", new GregorianCalendar());
            if (req.getParameter("url") != null) { bookmark.setProperty("url", req.getParameter("url")); }
            bookmark.setProperty("jcr:title", req.getParameter("jcr:title"));
            bookmark.saveSession();
        }
        return new ActionResult(HttpServletResponse.SC_OK, null, new JSONObject());
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.