Takes CmdbRequest and converts to Cmdb Object
@param request
@return Cmdb item
161714
private Cmdb requestToCmdb( CmdbRequest request ){
        Cmdb cmdb = new Cmdb();
        cmdb.setConfigurationItem( request.getConfigurationItem() );
        cmdb.setConfigurationItemSubType( request.getConfigurationItemSubType() );
        cmdb.setConfigurationItemType( request.getConfigurationItemType() );
        cmdb.setAssignmentGroup( request.getAssignmentGroup() );
        cmdb.setOwnerDept( request.getOwnerDept() );
        cmdb.setCommonName( request.getCommonName() );
        cmdb.setValidConfigItem( true );
        cmdb.setTimestamp( System.currentTimeMillis() );
        cmdb.setItemType( COMPONENT_TYPE );
        return cmdb;
    }
60593
@Override
	protected boolean doHandleRequest(final Request request) {
		String value = getRequestValue(request);
		String current = getValue();

		boolean changed = !Util.equals(value, current);

		if (changed) {
			setData(value);
		}

		return changed;
	}
1367767
public static ExceptionRequest fromProtobuf(TopologyMaster.ExceptionLogRequest request) {
    String componentName = request.getComponentName();

    Map<String, Set<String>> componentNameInstanceId = new HashMap<>();
    Set<String> instances = null;

    if (request.getInstancesCount() > 0) {
      instances = new HashSet<>();
      instances.addAll(request.getInstancesList());
    } // empty list means all instances; 'null' means all instances

    // only one component
    componentNameInstanceId.put(componentName, instances);

    return new ExceptionRequest(componentNameInstanceId);
  }
212623
public void performPersistCursorRequest(String name, long key, Request request) {
        persistentRequests.send(new PersistentRequestsActor.PerformCursorRequest(name, key, request));
    }
1019164
public Response makeRequest(final Request request) {

        HttpMethod method = request.getMethod();
        RequestBuilder builder = RequestBuilder.create(method.toString())
            .setUri(request.constructURL().toString())
            .setVersion(HttpVersion.HTTP_1_1)
            .setCharset(StandardCharsets.UTF_8);

        if (request.requiresAuthentication()) {
            builder.addHeader(HttpHeaders.AUTHORIZATION, request.getAuthString());
        }

        if (method == HttpMethod.POST) {
            builder.addHeader(HttpHeaders.CONTENT_TYPE, "application/x-www-form-urlencoded");

            for (Map.Entry<String, List<String>> entry : request.getPostParams().entrySet()) {
                for (String value : entry.getValue()) {
                    builder.addParameter(entry.getKey(), value);
                }
            }
        }

        HttpResponse response = null;

        try {
            response = client.execute(builder.build());
            HttpEntity entity = response.getEntity();
            return new Response(
                // Consume the entire HTTP response before returning the stream
                entity == null ? null : new BufferedHttpEntity(entity).getContent(),
                response.getStatusLine().getStatusCode()
            );
        } catch (IOException e) {
            throw new ApiException(e.getMessage(), e);
        } finally {

            // Ensure this response is properly closed
            HttpClientUtils.closeQuietly(response);

        }

    }
763592
public <T extends ApiObject> EntityList<T> get(Request<T> request)
    {
        return executeRequest(request,objectMapper.getTypeFactory()
                .constructParametrizedType(EntityList.class,EntityList.class, request.getEntityType()));
    }
850994
public ModelNode execute(ModelNode request) throws Exception {
        ModelControllerClient mcc = getModelControllerClient();
        return mcc.execute(request, OperationMessageHandler.logging);
    }
439701
public CompletableFuture<BackupResponse> backup(BackupRequest request) {
    ComposableFuture<BackupResponse> future = new ComposableFuture<>();
    threadContext.execute(() -> {
      role.backup(request).whenComplete(future);
    });
    return future;
  }
164963
public String processMultiDataSetRequest(final MultiDataSetRequest request) {
    StringBuilder sb = new StringBuilder();
    sb.append("Quandl codes ");
    final Iterator<QuandlCodeRequest> iter = request.getQuandlCodeRequests().iterator();
    while (iter.hasNext()) {
      QuandlCodeRequest req = iter.next();
      sb.append(req.getQuandlCode());
      if (req.isSingleColumnRequest()) {
        sb.append("[");
        sb.append(req.getColumnNumber());
        sb.append("]");
      }
      if (iter.hasNext()) {
        sb.append(",");
      }
    }
    if (request.getStartDate() != null) {
      sb.append(" from ");
      sb.append(request.getStartDate());
    }
    if (request.getEndDate() != null) {
      sb.append(" until ");
      sb.append(request.getEndDate());
    }
    if (request.getFrequency() != null) {
      sb.append(" sampled ");
      sb.append(request.getFrequency());
    }
    if (request.getSortOrder() != null) {
      sb.append(" sorted into ");
      sb.append(request.getSortOrder());
      sb.append(" order");
    }
    if (request.getTransform() != null) {
      sb.append(" transformed by ");
      sb.append(request.getTransform());
    }
    if (request.getMaxRows() != null) {
      sb.append(" with at most ");
      sb.append(request.getMaxRows());
      sb.append(" rows");
    }
    return sb.toString();
  }
1288755
public static Message buildRequest(ByteBuffer request) {
    Request req = Request.newBuilder()
                         .setRequest(ByteString.copyFrom(request))
                         .build();

    return Message.newBuilder().setType(MessageType.REQUEST)
                               .setRequest(req)
                               .build();
  }
1010492
private CollectorItem buildCollectorItem( CmdbRequest request, Collector collector ) {

        CollectorItem collectorItem = new CollectorItem();
        collectorItem.setCollectorId( collector.getId() );
        collectorItem.setEnabled( false );
        collectorItem.setPushed( true );
        collectorItem.setDescription( request.getCommonName() );
        collectorItem.setLastUpdated( System.currentTimeMillis() );
        collectorItem.getOptions().put( CONFIGURATION_ITEM, request.getConfigurationItem() );
        collectorItem.getOptions().put( COMMON_NAME, request.getCommonName() );

        return  collectorService.createCollectorItem( collectorItem );
    }
264526
public CommandResponse execute(GwtCommand request) {
		if (request != null) {
			return commandDispatcher.execute(request.getCommandName(), request.getCommandRequest(),
					request.getUserToken(), request.getLocale());
		}
		return null;
	}
655827
public Response request(final Request request) {
        request.setAuth(username, password);
        return httpClient.reliableRequest(request);
    }
1210932
@SuppressWarnings("unchecked")
	@Override
	public <T extends Resource> T request(final HttpRequestBase request) {
		try {
			HttpResponse response = execute(client, request);
			Resource resource = toPage(request, response);
			return (T)resource;
		} catch (Exception e) {
			throw MechanizeExceptionFactory.newException(e);
		}
	}
665628
public CopyObjectResponse copyObject(CopyObjectRequest request) {
        checkNotNull(request, "request should not be null.");
        assertStringNotNullOrEmpty(request.getSourceKey(), "object key should not be null or empty");

        InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT);

        String copySourceHeader = "/" + request.getSourceBucketName() + "/" + request.getSourceKey();
        copySourceHeader = HttpUtils.normalizePath(copySourceHeader);
        internalRequest.addHeader(Headers.BCE_COPY_SOURCE, copySourceHeader);
        if (request.getETag() != null) {
            internalRequest.addHeader(Headers.BCE_COPY_SOURCE_IF_MATCH,
                    "\"" + request.getETag() + "\"");
        }
        if (request.getNoneMatchETagConstraint() != null) {
            internalRequest.addHeader(
                    Headers.BCE_COPY_SOURCE_IF_NONE_MATCH, "\"" + request.getNoneMatchETagConstraint() + "\"");
        }
        if (request.getUnmodifiedSinceConstraint() != null) {
            internalRequest.addHeader(
                    Headers.BCE_COPY_SOURCE_IF_UNMODIFIED_SINCE, request.getUnmodifiedSinceConstraint());
        }
        if (request.getModifiedSinceConstraint() != null) {
            internalRequest.addHeader(
                    Headers.BCE_COPY_SOURCE_IF_MODIFIED_SINCE, request.getModifiedSinceConstraint());
        }
        if (request.getStorageClass() != null) {
            internalRequest.addHeader(Headers.BCE_STORAGE_CLASS, request.getStorageClass());
        }
        ObjectMetadata newObjectMetadata = request.getNewObjectMetadata();
        if (newObjectMetadata != null) {
            internalRequest.addHeader(Headers.BCE_COPY_METADATA_DIRECTIVE, "replace");
            populateRequestMetadata(internalRequest, newObjectMetadata);
        } else {
            internalRequest.addHeader(Headers.BCE_COPY_METADATA_DIRECTIVE, "copy");
        }

        this.setZeroContentLength(internalRequest);

        CopyObjectResponseWithExceptionInfo intermidiateRes = this.invokeHttpClient(internalRequest,
                CopyObjectResponseWithExceptionInfo.class);
        // handle exception
        if (intermidiateRes.getETag() == null 
                && intermidiateRes.getLastModified() == null) {
            if (intermidiateRes.getMessage() != null) {
                BceServiceException bse = new BceServiceException(intermidiateRes.getMessage());
                bse.setErrorCode(intermidiateRes.getCode());
                bse.setRequestId(intermidiateRes.getRequestId());
                if (bse.getErrorCode() == "InternalError") {
                    bse.setErrorType(ErrorType.Service);
                } else {
                    bse.setErrorType(ErrorType.Client);
                }
                bse.setStatusCode(HttpStatus.SC_INTERNAL_SERVER_ERROR);
                throw bse;
            }
        }
        return (CopyObjectResponse) intermidiateRes;
    }
552046
public static final DataGridStateFactory getInstance(ServletRequest request) {
        Object obj = request.getAttribute(KEY);
        if(obj != null) {
            assert obj instanceof DataGridStateFactory;
            return (DataGridStateFactory)obj;
        }
        else {
            DataGridStateFactory factory = new DataGridStateFactory(request);
            request.setAttribute(KEY, factory);
            return factory;
        }
    }
406748
public static ModelNode validateRequest(CommandContext ctx, ModelNode request) throws CommandFormatException {

        final Set<String> keys = request.keys();
        if (keys.size() == 2) { // no props
            return null;
        }
        ModelNode outcome = (ModelNode) ctx.get(Scope.REQUEST, DESCRIPTION_RESPONSE);
        if (outcome == null) {
            outcome = retrieveDescription(ctx, request, true);
            if (outcome == null) {
                return null;
            } else {
                ctx.set(Scope.REQUEST, DESCRIPTION_RESPONSE, outcome);
            }
        }
        if(!outcome.has(Util.RESULT)) {
            throw new CommandFormatException("Failed to perform " + Util.READ_OPERATION_DESCRIPTION + " to validate the request: result is not available.");
        }

        final String operationName = request.get(Util.OPERATION).asString();

        final ModelNode result = outcome.get(Util.RESULT);
        final Set<String> definedProps = result.hasDefined(Util.REQUEST_PROPERTIES) ? result.get(Util.REQUEST_PROPERTIES).keys() : Collections.emptySet();
        if(definedProps.isEmpty()) {
            if(!(keys.size() == 3 && keys.contains(Util.OPERATION_HEADERS))) {
                throw new CommandFormatException("Operation '" + operationName + "' does not expect any property.");
            }
        } else {
            int skipped = 0;
            for(String prop : keys) {
                if(skipped < 2 && (prop.equals(Util.ADDRESS) || prop.equals(Util.OPERATION))) {
                    ++skipped;
                    continue;
                }
                if(!definedProps.contains(prop)) {
                    if(!Util.OPERATION_HEADERS.equals(prop)) {
                        throw new CommandFormatException("'" + prop + "' is not found among the supported properties: " + definedProps);
                    }
                }
            }
        }
        return outcome;
    }