Writes a "create project" request.

@param writer
project writer.
@param project
project to create.
@throws IllegalArgumentException
if some project fields are not configured.
@throws JSONException
if IO error occurs.
321978
public static void writeProject(JSONWriter writer, Project project)
			throws IllegalArgumentException, JSONException {
		/* Validate project */
		if (project.getName() == null)
			throw new IllegalArgumentException(
					"Project name must be set to create a new project");
		if (project.getIdentifier() == null)
			throw new IllegalArgumentException(
					"Project identifier must be set to create a new project");

		writeProject(project, writer);
	}
557255
@Override
    public void writeValue(JsonGenerator g, Object value) throws IOException {
        write(value, g);
    }
293082
public Writer write(Writer writer) throws JSONException {
    try {
      boolean b = false;
      int len = length();

      writer.write('[');

      for (int i = 0; i < len; i += 1) {
        if (b) {
          writer.write(',');
        }
        Object v = this.myArrayList.get(i);
        if (v instanceof JSONObject) {
          ((JSONObject) v).write(writer);
        } else if (v instanceof JSONArray) {
          ((JSONArray) v).write(writer);
        } else {
          writer.write(JSONObject.valueToString(v));
        }
        b = true;
      }
      writer.write(']');
      return writer;
    } catch (IOException e) {
      throw new JSONException(e);
    }
  }
3303
public void serialize( JsonWriter writer, T bean, JsonSerializationContext ctx ) {
        Map map = getValue( bean, ctx );
        if ( null != map ) {
            ((MapJsonSerializer) getSerializer()).serializeValues( writer, map, ctx, getParameters() );
        }
    }
275918
private void writeRequest(String methodName, Object arguments, HttpRequest httpRequest) throws IOException {
		
		ObjectNode request = mapper.createObjectNode();
		request.put(ID, nextId.getAndIncrement());
		request.put(JSONRPC, JsonRpcBasicServer.VERSION);
		request.put(METHOD, methodName);
		
		if (arguments != null && arguments.getClass().isArray()) {
			Object[] args = Object[].class.cast(arguments);
			if (args.length > 0) {
				request.set(PARAMS, mapper.valueToTree(Object[].class.cast(arguments)));
			}
		} else if (arguments != null && Collection.class.isInstance(arguments)) {
			if (!Collection.class.cast(arguments).isEmpty()) {
				request.set(PARAMS, mapper.valueToTree(arguments));
			}
		} else if (arguments != null && Map.class.isInstance(arguments)) {
			if (!Map.class.cast(arguments).isEmpty()) {
				request.set(PARAMS, mapper.valueToTree(arguments));
			}
		} else if (arguments != null) {
			request.set(PARAMS, mapper.valueToTree(arguments));
		}
		
		logger.debug("JSON-PRC Request: {}", request);
		
		ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(512);
		mapper.writeValue(byteArrayOutputStream, request);
		HttpEntityEnclosingRequest entityRequest = (HttpEntityEnclosingRequest) httpRequest;
		
		HttpEntity entity;
		if (entityRequest.getFirstHeader("Content-Type") == null) {
			entity = new ByteArrayEntity(byteArrayOutputStream.toByteArray(), ContentType.APPLICATION_JSON);
		} else {
			entity = new ByteArrayEntity(byteArrayOutputStream.toByteArray());
		}
		entityRequest.setEntity(entity);
	}
742959
private void writeFileCreationRecord() throws IOException
   {
      ProjectProperties properties = m_projectFile.getProjectProperties();

      m_buffer.setLength(0);
      m_buffer.append("MPX");
      m_buffer.append(m_delimiter);
      m_buffer.append(properties.getMpxProgramName());
      m_buffer.append(m_delimiter);
      m_buffer.append(properties.getMpxFileVersion());
      m_buffer.append(m_delimiter);
      m_buffer.append(properties.getMpxCodePage());
      m_buffer.append(MPXConstants.EOL);
      m_writer.write(m_buffer.toString());
   }
1060335
public static ProjectWriter getProjectWriter(String name) throws InstantiationException, IllegalAccessException
   {
      int index = name.lastIndexOf('.');
      if (index == -1)
      {
         throw new IllegalArgumentException("Filename has no extension: " + name);
      }

      String extension = name.substring(index + 1).toUpperCase();

      Class<? extends ProjectWriter> fileClass = WRITER_MAP.get(extension);
      if (fileClass == null)
      {
         throw new IllegalArgumentException("Cannot write files of type: " + name);
      }

      ProjectWriter file = fileClass.newInstance();

      return (file);
   }
1308928
public void write(Workspace workspace, Writer writer) {
        if (workspace == null) {
            throw new IllegalArgumentException("A workspace must be provided.");
        }

        if (writer == null) {
            throw new IllegalArgumentException("A writer must be provided.");
        }

        workspace.getViews().getSystemLandscapeViews().forEach(v -> write(v, writer));
        workspace.getViews().getSystemContextViews().forEach(v -> write(v, writer));
        workspace.getViews().getContainerViews().forEach(v -> write(v, writer));
        workspace.getViews().getComponentViews().forEach(v -> write(v, writer));
        workspace.getViews().getDynamicViews().forEach(v -> write(v, writer));
        workspace.getViews().getDeploymentViews().forEach(v -> write(v, writer));
    }
721600
protected void write(Writer writer, WritingVisitor visitor) throws IOException {
      if( isNullObject() ){
         writer.write(JSONNull.getInstance().toString());
      }

      boolean b = false;
      Iterator keys = visitor.keySet(this).iterator();
      writer.write('{');

      while( keys.hasNext() ){
         if( b ){
            writer.write(',');
         }
         Object k = keys.next();
         writer.write(JSONUtils.quote(k.toString()));
         writer.write(':');
         Object v = this.properties.get(k);
         if( v instanceof JSON ){
            visitor.on((JSON) v, writer);
         }else{
            visitor.on(v, writer);
         }
         b = true;
      }
      writer.write('}');
   }
693362
public void write(JsonGenerator jsonGenerator) throws IOException {
    jsonGenerator.writeStartObject();

    int totalSessionsToCtx = 0, totalDeletedSessions = 0;
    for (int i = 0; i < numNotifierThreads; i++) {
      totalSessionsToCtx += notifierThreads[i].sessionsToCtx.size();
      totalDeletedSessions += notifierThreads[i].deletedSessions.size();
    }

    jsonGenerator.writeNumberField("totalSessionsToCtx",
                                    totalSessionsToCtx);

    jsonGenerator.writeFieldName("sessionsToCtx");
    jsonGenerator.writeStartObject();
    for (int i = 0; i < numNotifierThreads; i++) {
      for (ConcurrentMap.Entry<String, SessionNotificationCtx> entry :
        notifierThreads[i].sessionsToCtx.entrySet()) {
        jsonGenerator.writeFieldName(entry.getKey());
        entry.getValue().write(jsonGenerator);
      }
    }
    jsonGenerator.writeEndObject();

    jsonGenerator.writeNumberField("totalDeletedSessions",
                                    totalDeletedSessions);

    jsonGenerator.writeFieldName("deletedSessions");
    jsonGenerator.writeStartArray();
    for (int i = 0; i < numNotifierThreads; i++) {
      for (String deletedSessionHandle :
            notifierThreads[i].deletedSessions.keySet()) {
        jsonGenerator.writeString(deletedSessionHandle);
      }
    }
    jsonGenerator.writeEndArray();

    jsonGenerator.writeEndObject();
  }
1199759
public static Project parseProject(JSONObject content) throws JSONException {
		final Project result = new Project();
		result.setId(JsonInput.getInt(content, "id"));
		result.setIdentifier(JsonInput.getStringOrNull(content, "identifier"));
		result.setName(JsonInput.getStringNotNull(content, "name"));
		result.setDescription(JsonInput
				.getStringOrEmpty(content, "description"));
		result.setHomepage(JsonInput.getStringOrEmpty(content, "homepage"));
		result.setCreatedOn(getDateOrNull(content, "created_on"));
		result.setUpdatedOn(getDateOrNull(content, "updated_on"));
		final JSONObject parentProject = JsonInput.getObjectOrNull(content,
				"parent");
		if (parentProject != null)
			result.setParentId(JsonInput.getInt(parentProject, "id"));
		result.setTrackers(JsonInput.getListOrNull(content, "trackers",
				TRACKER_PARSER));
		return result;
	}
536501
@Override
    public void write(final Writer writer) throws ConfigurationException, IOException {
        Preconditions.checkNotNull(writer);

        @SuppressWarnings("unchecked") final
        HashMap<String, Object> settings = (HashMap<String, Object>) fromNode(this.getModel().getInMemoryRepresentation());
        this.mapper.writerWithDefaultPrettyPrinter().writeValue(writer, settings);
    }
788059
private void writeTasks(Project project)
   {
      Project.Tasks tasks = m_factory.createProjectTasks();
      project.setTasks(tasks);
      List<Project.Tasks.Task> list = tasks.getTask();

      for (Task task : m_projectFile.getTasks())
      {
         list.add(writeTask(task));
      }
   }
907400
private void writeObject(ObjectOutputStream stream) throws IOException {
        Utils.mapper().writeValue((DataOutput) stream, jsonObject);
    }
1017981
Writer write(Writer writer, int indentFactor, int indent)
            throws JSONException {
        try {
            boolean commanate = false;
            final int length = this.length();
            Iterator<String> keys = this.keys();
            writer.write('{');

            if (length == 1) {
                Object key = keys.next();
                writer.write(quote(key.toString()));
                writer.write(':');
                if (indentFactor > 0) {
                    writer.write(' ');
                }
                writeValue(writer, this.map.get(key), indentFactor, indent);
            } else if (length != 0) {
                final int newindent = indent + indentFactor;
                while (keys.hasNext()) {
                    Object key = keys.next();
                    if (commanate) {
                        writer.write(',');
                    }
                    if (indentFactor > 0) {
                        writer.write('\n');
                    }
                    indent(writer, newindent);
                    writer.write(quote(key.toString()));
                    writer.write(':');
                    if (indentFactor > 0) {
                        writer.write(' ');
                    }
                    writeValue(writer, this.map.get(key), indentFactor, newindent);
                    commanate = true;
                }
                if (indentFactor > 0) {
                    writer.write('\n');
                }
                indent(writer, indent);
            }
            writer.write('}');
            return writer;
        } catch (IOException exception) {
            throw new JSONException(exception);
        }
    }
1292982
public void write(JsonGenerator jsonGenerator) throws IOException {
    jsonGenerator.writeStartObject();

    jsonGenerator.writeStringField("handle", handle);

    jsonGenerator.writeStringField("host", host);

    jsonGenerator.writeNumberField("port", port);

    jsonGenerator.writeNumberField("numPendingCalls", pendingCalls.size());

    jsonGenerator.writeFieldName("pendingCalls");
    jsonGenerator.writeStartArray();
    for (TBase call : pendingCalls) {
      jsonGenerator.writeStartObject();

      // TBase is an abstract class. While reading back, we want to know
      // what kind of object we actually wrote. Jackson does provide two methods
      // to do it automatically, but one of them adds types at a lot of places
      // where we don't need it, and hence our parsing would be required to be
      // changed. The other required adding an annotation to the TBase class,
      // which we can't do, since it is auto-generated by Thrift.
      String callType = call.getClass().getName();
      jsonGenerator.writeStringField("callType", callType);

      jsonGenerator.writeObjectField("call", call);

      jsonGenerator.writeEndObject();
    }
    jsonGenerator.writeEndArray();

    jsonGenerator.writeEndObject();
  }
264221
private void write() throws IOException
   {
      m_projectFile.validateUniqueIDsForMicrosoftProject();

      writeFileCreationRecord();
      writeProjectHeader(m_projectFile.getProjectProperties());

      if (m_projectFile.getResources().isEmpty() == false)
      {
         m_resourceModel = new ResourceModel(m_projectFile, m_locale);
         m_writer.write(m_resourceModel.toString());
         for (Resource resource : m_projectFile.getResources())
         {
            writeResource(resource);
         }
      }

      if (m_projectFile.getTasks().isEmpty() == false)
      {
         m_taskModel = new TaskModel(m_projectFile, m_locale);
         m_writer.write(m_taskModel.toString());
         writeTasks(m_projectFile.getChildTasks());
      }

      m_writer.flush();
   }