Package org.codehaus.jackson.map

Examples of org.codehaus.jackson.map.ObjectWriter


        return false;
    }

    private void writeData(JsonNode rootNode, Writer fileWriter) throws Exception {
        ObjectWriter writer = mapper.writerWithDefaultPrettyPrinter();
       
        writer.writeValue(fileWriter, rootNode);
    }
View Full Code Here


    Reader input = new FileReader(inputFile);
    try {
      Writer output = new FileWriter(outputFile);
      try {
        ObjectMapper mapper = new ObjectMapper();
        ObjectWriter writer = mapper.defaultPrettyPrintingWriter();
        Iterator<Map> i = mapper.readValues(
                new JsonFactory().createJsonParser(input), Map.class);
        while (i.hasNext()) {
          Map m = i.next();
          output.write(writer.writeValueAsString(createSLSJob(m)) + EOL);
        }
      } finally {
        output.close();
      }
    } finally {
View Full Code Here

  private static void generateSLSNodeFile(String outputFile)
          throws IOException {
    Writer output = new FileWriter(outputFile);
    try {
      ObjectMapper mapper = new ObjectMapper();
      ObjectWriter writer = mapper.defaultPrettyPrintingWriter();
      for (Map.Entry<String, Set<String>> entry : rackNodeMap.entrySet()) {
        Map rack = new LinkedHashMap();
        rack.put("rack", entry.getKey());
        List nodes = new ArrayList();
        for (String name : entry.getValue()) {
          Map node = new LinkedHashMap();
          node.put("node", name);
          nodes.add(node);
        }
        rack.put("nodes", nodes);
        output.write(writer.writeValueAsString(rack) + EOL);
      }
    } finally {
      output.close();
    }
  }
View Full Code Here

  public @ResponseBody String processSubmit(@PathVariable("appId") int appId,
      @PathVariable("orgId") int orgId,
      @Valid @ModelAttribute Application application,
      BindingResult result, Model model) throws IOException {

        ObjectWriter writer = ControllerUtils.getObjectWriter(AllViews.FormInfo.class);

    if (!PermissionUtils.isAuthorized(Permission.CAN_MANAGE_APPLICATIONS, orgId, appId)) {
      return writer.writeValueAsString(RestResponse.failure("You don't have permission."));
    }
   
    Application databaseApplication = applicationService.loadApplication(appId);
    if (databaseApplication == null || !databaseApplication.isActive()) {
      log.warn(ResourceNotFoundException.getLogMessage("Application", appId));
      throw new ResourceNotFoundException();
    }
   
    // These should not be editable in this method.
    // TODO split into 3 controllers and use setAllowedFields
    application.setWaf(databaseApplication.getWaf());
    application.setDefectTracker(databaseApplication.getDefectTracker());
    application.setUserName(databaseApplication.getUserName());
    application.setPassword(databaseApplication.getPassword());
   
    if(!result.hasErrors()) {
      applicationService.validateAfterEdit(application, result);
    }
   
    if (application.getName() != null && application.getName().trim().equals("")
        && !result.hasFieldErrors("name")) {
      result.rejectValue("name", null, null, "This field cannot be blank");
    }

    if (result.hasErrors()) {
            PermissionUtils.addPermissions(model, orgId, appId, Permission.CAN_MANAGE_DEFECT_TRACKERS,
          Permission.CAN_MANAGE_WAFS);
     
      if (application.getWaf() != null && application.getWaf().getId() == null) {
        application.setWaf(null);
      }
     
      if (application.getDefectTracker() != null &&
          application.getDefectTracker().getId() == null) {
        application.setDefectTracker(null);
      }

      return writer.writeValueAsString(FormRestResponse.failure("Errors", result));

    } else {
      application.setOrganization(organizationService.loadById(application.getOrganization().getId()));
      applicationService.storeApplication(application);
            vulnerabilityService.updateOrgsVulnerabilityReport();
      String user = SecurityContextHolder.getContext().getAuthentication().getName();
     
      log.debug("The Application " + application.getName() + " (id=" + application.getId() + ") has been edited by user " + user);

            return writer.writeValueAsString(RestResponse.success(application));
    }
  }
View Full Code Here

            pageNumber = 1;
        }
   
    List<Scan> scans = scanService.getTableScans(pageNumber);

        ObjectWriter writer = ControllerUtils.getObjectWriter(AllViews.TableRow.class);

        Map<String, Object> map = new HashMap<>();
    map.put("scanList", scans);
    map.put("numScans", scanCount);
        return writer.writeValueAsString(RestResponse.success(map));
  }
View Full Code Here

                map.put("users", userService.getPermissibleUsers(orgId, null));
            }
            restResponse = RestResponse.success(map);
        }

        ObjectWriter writer = ControllerUtils.getObjectWriter(AllViews.TableRow.class);

        return writer.writeValueAsString(restResponse);
    }
View Full Code Here

      String[] targetedFieldNames = new String[fields.size()];
      for (int i = 0; i < fields.size(); i++) {
        targetedFieldNames[i] = fields.get(i).getName();
      }
      filters.addFilter("PropertyFilter", SimpleBeanPropertyFilter.filterOutAllExcept(targetedFieldNames));
      ObjectWriter objectWriter = objectMapper.writer(filters);
      String json = objectWriter.writeValueAsString(entity);

      /*
       * Encode property the custom way
       */
      List<java.lang.reflect.Field> customEncodedProperties = ClassUtil.getAnnotatedFields(entity, com.apitrary.orm.core.annotations.Codec.class);
View Full Code Here

    public static String writeSuccessObjectWithView(@Nonnull Object object, @Nonnull Class view) {
        ObjectMapper mapper = new ObjectMapper();
        mapper.configure(SerializationConfig.Feature.DEFAULT_VIEW_INCLUSION, false);

        ObjectWriter writer = mapper.writerWithView(view);

        try {
            return writer.writeValueAsString(RestResponse.success(object));
        } catch (IOException e) {
            throw new RuntimeException("Unable to write JSON Object.", e);
        }
    }
View Full Code Here

TOP

Related Classes of org.codehaus.jackson.map.ObjectWriter

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.