Preparing The JSON Response For The Data Source Cache Update.
@param validDataSources
@param invalidDataSources
@param cb
@returns {*}
185571
function prepareResponse(validDataSources, invalidDataSources, cb) {
  //There Were Errors Updating Data Sources, should return an error

  logger.debug("prepareResponse Before", validDataSources);
  //For The Valid Data Sources, Just want the updated Document JSON
  validDataSources = _.map(validDataSources, function(validDataSourceData) {
    return processDataSourceResponse(validDataSourceData.document.toJSON());
  });

  logger.debug("prepareResponse After", validDataSources);

  var returnError;
  if (invalidDataSources.length > 0) {
    returnError = buildErrorResponse({
      error: new Error("Error Updating Data Sources"),
      code: ERROR_CODES.FH_FORMS_UNEXPECTED_ERROR
    });
  }

  return cb(returnError, {
    validDataSourceUpdates: validDataSources,
    invalidDataSourceUpdates: invalidDataSources
  });
}
974563
@Override
    public String[] getjdbcDataSources() {
        final String methodName = "getjdbcDataSources()";
        final boolean trace = TraceComponent.isAnyTracingEnabled();
        if (trace && tc.isEntryEnabled())
            Tr.entry(tc, methodName, this);

        final Collection<JDBCDataSourceMBeanImpl> c = dataSourceMBeanChildrenList.values();
        final int size = c.size();
        final String[] result = new String[size];
        int index = 0;
        for (JDBCDataSourceMBeanImpl mbeanItem : c)
            result[index++] = mbeanItem.getobjectName();

        if (trace && tc.isEntryEnabled())
            Tr.exit(tc, methodName, this);
        return result;
        //return dataSourcesList.toArray(new String[dataSourcesList.size()]);
    }
1350273
function validateDataSource(connections, dataSource, cb) {
  var dataSourceToValidate = _.clone(dataSource);
  var DataSource = models.get(connections.mongooseConnection, models.MODELNAMES.DATA_SOURCE);

  //Expect The Data Source To Have Data
  var failure = validate(dataSourceToValidate).has(CONSTANTS.DATA_SOURCE_DATA);

  if (failure) {
    return cb(buildErrorResponse({
      error: new Error("No Data Passed To Validate"),
      code: ERROR_CODES.FH_FORMS_INVALID_PARAMETERS
    }));
  }

  //Generate A Hash
  var hash = misc.generateHash(dataSourceToValidate.data);

  //Populate A Cache Object
  //LastRefreshed is populated just for the cache mongoose schema
  var cache = {
    dataHash: hash,
    currentStatus: {
      status: "ok"
    },
    data: dataSourceToValidate.data,
    lastRefreshed: new Date().getTime(),
    updateTimestamp: new Date().getTime()
  };

  dataSourceToValidate.cache = [cache];

  //Create A New Mongoose. Note that this document is never saved. It is useful for consistent validation
  var testDataSource = new DataSource(dataSourceToValidate);
  //Validating Without Saving
  testDataSource.validate(function(err) {
    var valid = err ? false : true;
    var dataSourceJSON = testDataSource.toJSON();

    dataSourceJSON = processDataSourceResponse(dataSourceJSON);

    dataSourceJSON = _.omit(dataSourceJSON, "lastRefreshed", "currentStatus", "updateTimestamp", CONSTANTS.DATA_SOURCE_ID);

    dataSourceJSON.validationResult = {
      valid: valid,
      message: valid ? "Data Source Is Valid" : "Invalid Data Source Update Data."
    };

    return cb(undefined, dataSourceJSON);
  });
}
178116
public static JsonSchema createFromSource(final Reader reader) throws InvalidSchemaException, URISyntaxException {

		final Gson gson                      = new GsonBuilder().create();
		final Map<String, Object> rawData    = gson.fromJson(reader, Map.class);

		return StructrSchemaDefinition.initializeFromSource(rawData);
	}
975389
private CDCResponse getCDCQueryResponse(JsonNode jsonNode) throws IOException {
		ObjectMapper mapper = new ObjectMapper();

		SimpleModule simpleModule = new SimpleModule("CDCQueryResponseDeserializer", new Version(1, 0, 0, null));
		simpleModule.addDeserializer(CDCResponse.class, new CDCQueryResponseDeserializer());

		mapper.registerModule(simpleModule);

		return mapper.treeToValue(jsonNode, CDCResponse.class);
	}
126794
function updateValidAndInvalidDataSources(dataSourcesToSplit, currentInvalidDataSources) {
  logger.debug("dataSourcesToSplit", dataSourcesToSplit);
  currentInvalidDataSources = currentInvalidDataSources || [];
  var validInvalid = _.partition(dataSourcesToSplit, function(dataSourceUpdateData) {
    if (dataSourceUpdateData) {
      return !dataSourceUpdateData.error;
    }
    return true;
  });

  var validDataSources = validInvalid[0];

  //Updating any data sources that are no longer valid
  var invalidDataSources = _.union(validInvalid[1], currentInvalidDataSources);

  return {
    valid: validDataSources,
    invalid: invalidDataSources
  };
}
660535
private void doGetDatasources() throws PageException {

	Map ds = config.getDataSourcesAsMap();
	Iterator it = ds.keySet().iterator();
	lucee.runtime.type.Query qry = new QueryImpl(new String[] { "name", "host", "classname", "bundleName", "bundleVersion", "dsn", "DsnTranslated", "database", "port",
		"timezone", "username", "password", "passwordEncrypted", "readonly", "grant", "drop", "create", "revoke", "alter", "select", "delete", "update", "insert",
		"connectionLimit", "openConnections", "connectionTimeout", "clob", "blob", "validate", "storage", "customSettings", "metaCacheTimeout" }, ds.size(), "query");

	int row = 0;

	while (it.hasNext()) {
	    Object key = it.next();
	    DataSource d = (DataSource) ds.get(key);
	    row++;

	    qry.setAt(KeyConstants._name, row, key);
	    qry.setAt(KeyConstants._host, row, d.getHost());
	    qry.setAt("classname", row, d.getClassDefinition().getClassName());
	    qry.setAt("bundleName", row, d.getClassDefinition().getName());
	    qry.setAt("bundleVersion", row, d.getClassDefinition().getVersionAsString());
	    qry.setAt("dsn", row, d.getDsnOriginal());
	    qry.setAt("database", row, d.getDatabase());
	    qry.setAt(KeyConstants._port, row, d.getPort() < 1 ? "" : Caster.toString(d.getPort()));
	    qry.setAt("dsnTranslated", row, d.getDsnTranslated());
	    qry.setAt("timezone", row, toStringTimeZone(d.getTimeZone()));
	    qry.setAt(KeyConstants._password, row, d.getPassword());

	    qry.setAt("passwordEncrypted", row, ConfigWebUtil.encrypt(d.getPassword()));
	    qry.setAt(KeyConstants._username, row, d.getUsername());
	    qry.setAt(KeyConstants._readonly, row, Caster.toBoolean(d.isReadOnly()));
	    qry.setAt(KeyConstants._select, row, Boolean.valueOf(d.hasAllow(DataSource.ALLOW_SELECT)));
	    qry.setAt(KeyConstants._delete, row, Boolean.valueOf(d.hasAllow(DataSource.ALLOW_DELETE)));
	    qry.setAt(KeyConstants._update, row, Boolean.valueOf(d.hasAllow(DataSource.ALLOW_UPDATE)));
	    qry.setAt(KeyConstants._create, row, Boolean.valueOf(d.hasAllow(DataSource.ALLOW_CREATE)));
	    qry.setAt(KeyConstants._insert, row, Boolean.valueOf(d.hasAllow(DataSource.ALLOW_INSERT)));
	    qry.setAt(KeyConstants._drop, row, Boolean.valueOf(d.hasAllow(DataSource.ALLOW_DROP)));
	    qry.setAt(KeyConstants._grant, row, Boolean.valueOf(d.hasAllow(DataSource.ALLOW_GRANT)));
	    qry.setAt(KeyConstants._revoke, row, Boolean.valueOf(d.hasAllow(DataSource.ALLOW_REVOKE)));
	    qry.setAt(KeyConstants._alter, row, Boolean.valueOf(d.hasAllow(DataSource.ALLOW_ALTER)));
	    int oc = config.getDatasourceConnectionPool().openConnections(key.toString());
	    qry.setAt("openConnections", row, oc < 0 ? 0 : oc);
	    qry.setAt("connectionLimit", row, d.getConnectionLimit() < 1 ? "" : Caster.toString(d.getConnectionLimit()));
	    qry.setAt("connectionTimeout", row, d.getConnectionTimeout() < 1 ? "" : Caster.toString(d.getConnectionTimeout()));
	    qry.setAt("customSettings", row, d.getCustoms());
	    qry.setAt("blob", row, Boolean.valueOf(d.isBlob()));
	    qry.setAt("clob", row, Boolean.valueOf(d.isClob()));
	    qry.setAt("validate", row, Boolean.valueOf(d.validate()));
	    qry.setAt("storage", row, Boolean.valueOf(d.isStorage()));
	    qry.setAt("metaCacheTimeout", row, Caster.toDouble(d.getMetaCacheTimeout()));

	}
	pageContext.setVariable(getString("admin", action, "returnVariable"), qry);
    }
338177
function validated(invalid){
            if (invalid) { return callback(invalid) }
            if(options.coerce){crudUtils.coerceData(options,coerced())}
            else{coerced(null,options.data)}
        }
892793
public ActionFuture<IndexResponse> sendDataAsyncWithObjectMapper(
            Object sourceObject, String index, String type, String id) {
        return indexQueryAsync(buildIndexRequest(
                JMElasticsearchUtil.buildSourceByJsonMapper(sourceObject),
                index, type, id));
    }
315169
public void setDatasource(Object datasource) throws PageException, ClassException, BundleException {
	if (datasource == null) return;
	data.rawDatasource = datasource;
	data.datasource = toDatasource(pageContext, datasource);
    }
869249
public final void invalidateKey(Data key, String dataStructureName, String sourceUuid) {
        checkNotNull(key, "key cannot be null");
        checkNotNull(sourceUuid, "sourceUuid cannot be null");

        Invalidation invalidation = newKeyInvalidation(key, dataStructureName, sourceUuid);
        invalidateInternal(invalidation, getPartitionId(key));
    }
783648
protected void invalidateCacheEntry(String spaceId, String key, Object data) {
        if (isCacheEnabled()) {
            putToCache(getCacheName(), calcCacheKey(spaceId, key), data);
        }
    }
106284
function(data_source) {

		if (Lava.schema.DEBUG && typeof(data_source) != 'object') Lava.t("Wrong argument passed to updateFromSourceObject");

		if (Array.isArray(data_source)) {

			this._updateFromArray(data_source, []);

		} else if (data_source.isCollection) {

			this._updateFromEnumerable(data_source);

		} else {

			this._updateFromObject(data_source.isProperties ? data_source.getProperties() : data_source);

		}

	}
876565
@GET
  @Path("/{dataSourceName}/intervals/{interval}/serverview")
  @Produces(MediaType.APPLICATION_JSON)
  @ResourceFilters(DatasourceResourceFilter.class)
  public Response getSegmentDataSourceSpecificInterval(
      @PathParam("dataSourceName") String dataSourceName,
      @PathParam("interval") String interval,
      @QueryParam("partial") final boolean partial
  )
  {
    TimelineLookup<String, SegmentLoadInfo> timeline = serverInventoryView.getTimeline(
        new TableDataSource(dataSourceName)
    );
    final Interval theInterval = Intervals.of(interval.replace('_', '/'));
    if (timeline == null) {
      log.debug("No timeline found for datasource[%s]", dataSourceName);
      return Response.ok(new ArrayList<ImmutableSegmentLoadInfo>()).build();
    }

    Iterable<TimelineObjectHolder<String, SegmentLoadInfo>> lookup = timeline.lookupWithIncompletePartitions(theInterval);
    FunctionalIterable<ImmutableSegmentLoadInfo> retval = FunctionalIterable
        .create(lookup).transformCat(
            (TimelineObjectHolder<String, SegmentLoadInfo> input) ->
                Iterables.transform(
                    input.getObject(),
                    (PartitionChunk<SegmentLoadInfo> chunk) ->
                        chunk.getObject().toImmutableSegmentLoadInfo()
                )
        );
    return Response.ok(retval).build();
  }
894990
private boolean readMetaData() throws InvalidDataException {
		final ByteBuffer buf = storage.get(0);
		int magic1, magic2, t_b_order_leaf, t_b_order_internal, t_blockSize; // sanity
		boolean isClean = false;
		magic1 = buf.getInt();
		if (magic1 != MAGIC_1) {
			throw new InvalidDataException("Invalid metadata (MAGIC1)");
		}
		t_blockSize = buf.getInt();
		if (t_blockSize != blockSize) {
			throw new InvalidDataException("Invalid metadata (blockSize) " + t_blockSize + " != " + blockSize);
		}
		t_b_order_leaf = buf.getInt();
		t_b_order_internal = buf.getInt();
		if (t_b_order_leaf != b_order_leaf) {
			throw new InvalidDataException("Invalid metadata (b-order leaf) " + t_b_order_leaf + " != "
					+ b_order_leaf);
		}
		if (t_b_order_internal != b_order_internal) {
			throw new InvalidDataException("Invalid metadata (b-order internal) " + t_b_order_internal
					+ " != " + b_order_internal);
		}
		storageBlock = buf.getInt();
		rootIdx = buf.getInt();
		lowIdx = buf.getInt();
		highIdx = buf.getInt();
		elements = buf.getInt();
		height = buf.getInt();
		maxInternalNodes = buf.getInt();
		maxLeafNodes = buf.getInt();
		isClean = ((buf.get() == ((byte) 0xEA)) ? true : false);
		magic2 = buf.getInt();
		if (magic2 != MAGIC_2) {
			throw new InvalidDataException("Invalid metadata (MAGIC2)");
		}
		if (log.isDebugEnabled()) {
			log.debug(this.getClass().getName() + "::readMetaData() elements=" + elements + " rootIdx="
					+ rootIdx);
		}
		storage.release(buf);
		// Clear Caches
		clearReadCaches();
		clearWriteCaches();
		if (isClean && fileFreeBlocks.exists()) {
			try {
				final SimpleBitSet newFreeBlocks = SimpleBitSet.deserializeFromFile(fileFreeBlocks);
				freeBlocks = newFreeBlocks;
			} catch (IOException e) {
				log.error("IOException in readMetaData()", e);
			}
		}
		return isClean;
	}
1127622
function updateDataSourceCaches(params, dsWithDocuments, dsWithNoDocuments, cb) {
  //Updating All Of The Data Sources
  //Generating Hashes For The Incoming Data Set. Useful for determining if the stored data set has changed.
  dsWithDocuments = _.map(dsWithDocuments, function(dataSourceData) {
    dataSourceData.dataHash = dataSourceData.error ? null : misc.generateHash(dataSourceData.data);
    return dataSourceData;
  });

  async.map(dsWithDocuments, function(dataSourceWithDocument, cb) {
    return updateDataSourceEntry(params, dataSourceWithDocument, cb);
  }, function(err, updatedDocuments) {

    logger.debug("ARGUMENTS", arguments);
    //Documents are now either updated or failed
    var validInvalidDataSources = updateValidAndInvalidDataSources(updatedDocuments, dsWithNoDocuments);

    return cb(undefined, validInvalidDataSources.valid, validInvalidDataSources.invalid);
  });
}
70030
public ActionFuture<UpdateResponse> upsertDataAsync(
            Map<String, ?> source, String index, String type, String id) {
        return upsertQueryAsync(buildPrepareUpsert(index, type, id, source));
    }