Source from a stream

@param identity identity
@param content  yaml string
@param modified date the content was last modified, for caching purposes

@return source
430342
public static CacheableYamlSource sourceFromString(
        final String identity,
        final String content,
        final Date modified,
        final ValidationSet validation
    )
    {
        return new CacheableYamlSource() {
            @Override
            public boolean isValid() {
                return true;
            }

            @Override
            public Date getLastModified() {
                return modified;
            }

            @Override
            public String getIdentity() {
                return identity;
            }

            @Override
            public Iterable<ACLPolicyDoc> loadAll(final Yaml yaml) throws IOException {
                return YamlParsePolicy.documentIterable(yaml.loadAll(content).iterator(), validation, identity);
            }

            @Override
            public ValidationSet getValidationSet() {
                return validation;
            }

            @Override
            public void close() throws IOException {

            }
        };
    }
768324
@Override
    public TemplateContentData get(String identifier) {
        Object lock = locksMap.get(identifier);
        if (lock != null) {
            synchronized (lock) {
                AccessOrderedTemplateContentData data = templateDataMap.get(identifier);
                if ((data != null) && templateOrderQueue.contains(data)) {
                    templateOrderQueue.remove(data);
                    if (isFresh(data)) {
                        TemplateContentData templateContentData = data.getTemplateContentData();
                        templateOrderQueue.offer(data);
                        return templateContentData;
                    }
                    templateDataMap.remove(identifier);
                    deductAndGet(data.getTemplateContentData().getTemplateContent().length);
                    LOGGER.warn(String.format("Template: %s is out of date, removing.", identifier));
                }
            }
        }
        return null;
    }
667855
private Identity build(BatchProto.Identity identityProto) {
        Identity identity = new Identity();
        identity.setChannelId(identityProto.getChannelId());
        identity.setPipelineId(identityProto.getPipelineId());
        identity.setProcessId(identityProto.getProcessId());
        return identity;
    }
51072
public static ContentSource getInputContentSource(Configuration conf) 
    throws URISyntaxException, XccConfigException, IOException {
        String host = conf.getStrings(INPUT_HOST)[0];
        if (host == null || host.isEmpty()) {
            throw new IllegalArgumentException(INPUT_HOST + 
                    " is not specified.");
        }
        
        return getInputContentSource(conf, host);
    }
375553
public static String getEntityId(I_CmsXmlContentValue contentValue) {

        String result = CmsContentDefinition.uuidToEntityId(
            contentValue.getDocument().getFile().getStructureId(),
            contentValue.getLocale().toString());
        String valuePath = contentValue.getPath();
        if (valuePath.contains("/")) {
            result += "/" + valuePath.substring(0, valuePath.lastIndexOf("/"));
        }
        if (contentValue.isChoiceOption()) {
            result += "/"
                + CmsType.CHOICE_ATTRIBUTE_NAME
                + "_"
                + contentValue.getName()
                + "["
                + contentValue.getXmlIndex()
                + "]";
        }
        return result;
    }
375261
public Request setContent(InputStream stream, ContentType contentType) {
        entity = new InputStreamEntity(stream, contentType);
        return this;
    }
1315786
public Date modifyDatastreamByReference(Context context,
                                            String pid,
                                            String datastreamID,
                                            String[] altIDs,
                                            String dsLabel,
                                            String mimeType,
                                            String formatURI,
                                            String dsLocation,
                                            String checksumType,
                                            String checksum,
                                            String logMessage,
                                            Date lastModifiedDate)
            throws ServerException {
        throw rejectCallsFromOutsideWhileInRecoveryMode();
    }
784525
private static Request make(final Identity identity, final String header,
        final Request req) throws IOException {
        return new RqWithHeader(
            req,
            header,
            new Utf8String(new CcPlain().encode(identity)).asString()
        );
    }
552373
public static Identity createExtendedIdentity(Document doc) throws MarshalException {
		String idName = DomHelpers.prepareExtendedIdentifier(doc);
		return createIdentity(IdentityType.other, idName, null,
				IfmapStrings.OTHER_TYPE_EXTENDED_IDENTIFIER);
	}
687034
public ResourceModelSource createCachingSource(
            ResourceModelSource origin,
            String ident,
            String descr,
            SourceFactory.CacheType type,
            final boolean logging
    )
    {
        final File file = getResourceModelSourceFileCacheForType(ident);
        final ResourceModelSourceService nodesSourceService = resourceModelSourceService;
        final ResourceFormatGeneratorService resourceFormatGeneratorService = getResourceFormatGeneratorService();
        final Properties fileSourceConfig = generateFileSourceConfigurationProperties(
                file.getAbsolutePath(),
                ResourceXMLFormatGenerator.SERVICE_PROVIDER_TYPE, false, false
        );
        try {
            ResourceModelSource fileSource = nodesSourceService.getSourceForConfiguration("file", fileSourceConfig);

            ResourceFormatGenerator generatorForFormat = resourceFormatGeneratorService.getGeneratorForFormat
                    (ResourceXMLFormatGenerator.SERVICE_PROVIDER_TYPE);

            String ident1 = "[ResourceModelSource: " + descr + ", project: " + projectConfig.getName() + "]";
            StoreExceptionHandler handler = new StoreExceptionHandler(ident);
            ResourceModelSourceCache cache = new FileResourceModelSourceCache(
                    file,
                    generatorForFormat,
                    fileSource
            );
            if(logging) {
                cache = new LoggingResourceModelSourceCache(cache, ident1);
            }
            return SourceFactory.cachedSource(
                    origin,
                    ident1,
                    handler,
                    cache,
                    type
            );
        } catch (UnsupportedFormatException | ExecutionServiceException e) {
            e.printStackTrace();
        }
        return null;
    }
643374
public static Identity createExtendedIdentity(String extendedIdentifier,
			Charset c) throws MarshalException {
		return createExtendedIdentity(DomHelpers.toDocument(extendedIdentifier, c));
	}
1196447
public static BinaryDocument create(String id, ByteBuf content) {
        return new BinaryDocument(id, 0, content, 0, null);
    }
1360651
public static Map<String, Object> identityMap(CouchbaseEvent source) {
        Map<String, Object> root = new HashMap<String, Object>();
        Map<String, String> event = new HashMap<String, String>();

        event.put("name", source.getClass().getSimpleName().replaceAll("Event$", ""));
        event.put("type", source.type().toString());
        root.put("event", event);

        return root;
    }
1235226
public static JsonArrayDocument create(String id, JsonArray content) {
        return new JsonArrayDocument(id, 0, content, 0, null);
    }
1280487
protected CmsResource createFakeBinaryFile(String rootPath, long dateLastModified) throws CmsLoaderException {

        CmsUUID structureId = CmsUUID.getConstantUUID("s-" + rootPath);
        CmsUUID resourceId = CmsUUID.getConstantUUID("r-" + rootPath);
        @SuppressWarnings("deprecation")
        int type = OpenCms.getResourceManager().getResourceType(CmsResourceTypeBinary.getStaticTypeName()).getTypeId();
        boolean isFolder = false;
        int flags = 0;
        CmsUUID projectId = CmsProject.ONLINE_PROJECT_ID;
        CmsResourceState state = CmsResource.STATE_UNCHANGED;
        long dateCreated = 0;
        long dateReleased = 1;
        long dateContent = 1;
        int version = 0;

        CmsUUID userCreated = CmsUUID.getNullUUID();
        CmsUUID userLastModified = CmsUUID.getNullUUID();
        long dateExpired = Integer.MAX_VALUE;
        int linkCount = 0;
        int size = 1;

        CmsResource resource = new CmsResource(
            structureId,
            resourceId,
            rootPath,
            type,
            isFolder,
            flags,
            projectId,
            state,
            dateCreated,
            userCreated,
            dateLastModified,
            userLastModified,
            dateReleased,
            dateExpired,
            linkCount,
            size,
            dateContent,
            version);
        return resource;
    }
96190
public <T> T markModified(T source) {

		Assert.notNull(source, "Entity must not be null!");

		return touch(source, false);
	}
1268181
static PluginMeta loadMetadataYaml(final InputStream stream) {
        final Yaml yaml = new Yaml();

        return yaml.loadAs(stream, PluginMeta.class);
    }