• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java FileContentStore类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.alfresco.repo.content.filestore.FileContentStore的典型用法代码示例。如果您正苦于以下问题:Java FileContentStore类的具体用法?Java FileContentStore怎么用?Java FileContentStore使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



FileContentStore类属于org.alfresco.repo.content.filestore包,在下文中一共展示了FileContentStore类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: checkAndGetStore

import org.alfresco.repo.content.filestore.FileContentStore; //导入依赖的package包/类
/**
 * Check that the given store name is in the list. 
 * Also check it's an instance of {@link FileContentStore}. If it's not, output a warning
 * as non-file-based implementations have not been tested and may be unsupported.
 * 
 * @param storeName	the store name to check
 */
public ContentStore checkAndGetStore(String storeName)
{
	ContentStore store = storeMap.get(storeName);
   	if(store == null)
   	{
   		String validStores ="";
        	Iterator<String> it = storeMap.keySet().iterator();
        	while (it.hasNext()) 
        	{
        		validStores += "'" + it.next() + "'" + (it.hasNext() ? " , " : "");
        	}
        	throw new IllegalArgumentException("given store name : '" + storeName + "' is not part of the registered stores : " + validStores);
        }
        if(!(store instanceof FileContentStore))
        {
       	 // letting you off with a warning :)
       	 // some people may have a custom content store for which the import could work in this case too ...
       	 if(logger.isWarnEnabled())
       	 {
       		 logger.warn("selected store '" + storeName + "' is not a FileContentStore. Is the implementation based on local files ?");
       	 }
        }
        
        return store;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:33,代码来源:AbstractContentStoreMapProvider.java


示例2: init

import org.alfresco.repo.content.filestore.FileContentStore; //导入依赖的package包/类
/**
 * Service initialise 
 */
public void init()
{
    // Set up a temporary store
    this.tempStore = new FileContentStore(this.applicationContext, TempFileProvider.getTempDir().getAbsolutePath());

    // Bind on update properties behaviour
    this.policyComponent.bindClassBehaviour(
            NodeServicePolicies.OnUpdatePropertiesPolicy.QNAME,
            this,
            new JavaBehaviour(this, "onUpdateProperties"));
    
    // Register on content update policy
    this.onContentUpdateDelegate = this.policyComponent.registerClassPolicy(OnContentUpdatePolicy.class);
    this.onContentPropertyUpdateDelegate = this.policyComponent.registerClassPolicy(OnContentPropertyUpdatePolicy.class);
    this.onContentReadDelegate = this.policyComponent.registerClassPolicy(OnContentReadPolicy.class);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:20,代码来源:ContentServiceImpl.java


示例3: initContentStore

import org.alfresco.repo.content.filestore.FileContentStore; //导入依赖的package包/类
protected ContentStore initContentStore(ApplicationContext ctx, String contentRoot)
{
	Map<String, Serializable> extendedEventParams = new HashMap<String, Serializable>();
	if (!TenantService.DEFAULT_DOMAIN.equals(tenantService.getCurrentUserDomain()))
	{
	    extendedEventParams.put("Tenant", tenantService.getCurrentUserDomain());
	}

    FileContentStore fileContentStore = new FileContentStore(ctx, new File(contentRoot), extendedEventParams);
    
    // Set the content filesize limiter if there is one.
    if (this.contentLimitProvider != null)
    {
        fileContentStore.setContentLimitProvider(contentLimitProvider);
    }
    
    if(fileContentUrlProvider != null)
    {
        fileContentStore.setFileContentUrlProvider(fileContentUrlProvider);
    }
    return fileContentStore;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:23,代码来源:TenantRoutingFileContentStore.java


示例4: before

import org.alfresco.repo.content.filestore.FileContentStore; //导入依赖的package包/类
@Before
public void before() throws Exception
{
    File tempDir = TempFileProvider.getTempDir();
    // create a primary file store
    String storeDir = tempDir.getAbsolutePath() + File.separatorChar + GUID.generate();
    primaryStore = new FileContentStore(ctx, storeDir);
    // create some secondary file stores
    secondaryStores = new ArrayList<ContentStore>(3);
    for (int i = 0; i < 4; i++)
    {
        storeDir = tempDir.getAbsolutePath() + File.separatorChar + GUID.generate();
        FileContentStore store = new FileContentStore(ctx, storeDir);
        secondaryStores.add(store);
    }
    // Create the aggregating store
    aggregatingStore = new AggregatingContentStore();
    aggregatingStore.setPrimaryStore(primaryStore);
    aggregatingStore.setSecondaryStores(secondaryStores);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:21,代码来源:AggregatingContentStoreTest.java


示例5: before

import org.alfresco.repo.content.filestore.FileContentStore; //导入依赖的package包/类
@Before
public void before() throws Exception
{
    File tempDir = TempFileProvider.getTempDir();
    // Create a subdirectory for A
    File storeADir = new File(tempDir, "A");
    storeA = new FileContentStore(ctx, storeADir);
    // Create a subdirectory for B
    File storeBDir = new File(tempDir, "B");
    storeB = new FileContentStore(ctx, storeBDir);
    // Create a subdirectory for C
    File storeCDir = new File(tempDir, "C");
    storeC = new DumbReadOnlyFileStore(new FileContentStore(ctx, storeCDir));
    // No subdirectory for D
    storeD = new SupportsNoUrlFormatStore();
    // Create the routing store
    routingStore = new RandomRoutingContentStore(storeA, storeB, storeC, storeD);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:19,代码来源:RoutingContentStoreTest.java


示例6: testMissingUrl

import org.alfresco.repo.content.filestore.FileContentStore; //导入依赖的package包/类
/**
 * Checks that requests for missing content URLs are served.
 */
@Test
public void testMissingUrl()
{
    String missingContentUrl = FileContentStore.createNewFileStoreUrl();
    
    ContentReader reader = routingStore.getReader(missingContentUrl);
    assertNotNull("Missing URL should not return null", reader);
    assertFalse("Empty reader should say content doesn't exist.", reader.exists());
    try
    {
        reader.getContentString();
        fail("Empty reader cannot return content.");
    }
    catch (Throwable e)
    {
        // Expected
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:22,代码来源:RoutingContentStoreTest.java


示例7: writeToCacheWithExistingReader

import org.alfresco.repo.content.filestore.FileContentStore; //导入依赖的package包/类
@Test
public void writeToCacheWithExistingReader()
{   
    ContentWriter oldWriter = store.getWriter(ContentContext.NULL_CONTEXT);
    oldWriter.putContent("Old content for " + getClass().getSimpleName());
    ContentReader existingReader = oldWriter.getReader();
    
    // Write through the caching content store - cache during the process.
    final String proposedUrl = FileContentStore.createNewFileStoreUrl();
    ContentWriter writer = store.getWriter(new ContentContext(existingReader, proposedUrl));
    final String content = makeContent();
    writer.putContent(content);
    assertEquals("Writer should have correct URL", proposedUrl, writer.getContentUrl());
    
    assertFalse("Old and new writers must have different URLs",
                oldWriter.getContentUrl().equals(writer.getContentUrl()));
    
    ContentReader reader = store.getReader(writer.getContentUrl());
    assertEquals("Reader and writer should have same URLs", writer.getContentUrl(), reader.getContentUrl());
    assertEquals("Reader should get correct content", content, reader.getContentString());
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:22,代码来源:FullTest.java


示例8: createNewUrl

import org.alfresco.repo.content.filestore.FileContentStore; //导入依赖的package包/类
public static String createNewUrl() {

		Calendar calendar = new GregorianCalendar();
		int year = calendar.get(Calendar.YEAR);
		int month = calendar.get(Calendar.MONTH) + 1; // 0-based
		int day = calendar.get(Calendar.DAY_OF_MONTH);
		int hour = calendar.get(Calendar.HOUR_OF_DAY);
		int minute = calendar.get(Calendar.MINUTE);
		// create the URL
		StringBuilder sb = new StringBuilder(20);
		sb.append(FileContentStore.STORE_PROTOCOL)
				.append(ContentStore.PROTOCOL_DELIMITER).append(year)
				.append('/').append(month).append('/').append(day).append('/')
				.append(hour).append('/').append(minute).append('/')
				.append(GUID.generate()).append(".bin");
		String newContentUrl = sb.toString();
		// done
		return newContentUrl;

	}
 
开发者ID:EisenVault,项目名称:ev-alfresco-azure-adapter,代码行数:21,代码来源:AzureContentStore.java


示例9: isInContentStore

import org.alfresco.repo.content.filestore.FileContentStore; //导入依赖的package包/类
/**
 * Determines whether the given file is located in the given file content store.
 * @param fileContentStore The file content store to check <i>(must not be null)</i>.
 * @param source           The file to check <i>(must not be null)</i>.
 * @return True if the given file is in an Alfresco managed content store, false otherwise.
 */
private final boolean isInContentStore(final FileContentStore fileContentStore, final File source)
{
    boolean result            = false;
    String  storeRootLocation = fileContentStore.getRootLocation();
    String  sourcePath        = source.getAbsolutePath();   // Note: we don't use getCanonicalPath here because it dereferences symlinks (which we don't want)
    
    // Case insensitive comparison on Windows
    if (SystemUtils.IS_OS_WINDOWS)
    {
        result = sourcePath.toLowerCase().startsWith(storeRootLocation.toLowerCase());
    }
    else
    {
        result = sourcePath.startsWith(storeRootLocation);
    }
    
    return(result);
}
 
开发者ID:pmonks,项目名称:alfresco-bulk-filesystem-import,代码行数:25,代码来源:AbstractBulkFilesystemImporter.java


示例10: initContentStore

import org.alfresco.repo.content.filestore.FileContentStore; //导入依赖的package包/类
protected ContentStore initContentStore(ApplicationContext ctx, String contentRoot)
{
	Map<String, Serializable> extendedEventParams = new HashMap<String, Serializable>();
	if (!TenantService.DEFAULT_DOMAIN.equals(tenantService.getCurrentUserDomain()))
	{
	    extendedEventParams.put("Tenant", tenantService.getCurrentUserDomain());
	}

    FileContentStore fileContentStore = new FileContentStore(ctx, new File(contentRoot), extendedEventParams);
    
    // Set the content filesize limiter if there is one.
    if (this.contentLimitProvider != null)
    {
        fileContentStore.setContentLimitProvider(contentLimitProvider);
    }
    
    return fileContentStore;
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:19,代码来源:TenantRoutingFileContentStore.java


示例11: setUp

import org.alfresco.repo.content.filestore.FileContentStore; //导入依赖的package包/类
@Override
public void setUp() throws Exception
{
    super.setUp();
    
    // Create a dummy context for message broadcasting
    StaticApplicationContext ctx = new StaticApplicationContext();
    ctx.refresh();
    
    File tempDir = TempFileProvider.getTempDir();
    // create the source file store
    String storeDir = tempDir.getAbsolutePath() + File.separatorChar + getName() + File.separatorChar + GUID.generate();
    sourceStore = new FileContentStore(ctx, storeDir);
    // create the target file store
    storeDir = tempDir.getAbsolutePath() + File.separatorChar + getName() + File.separatorChar + GUID.generate();
    targetStore = new FileContentStore(ctx, storeDir);
    
    // create the replicator 
    replicator = new ContentStoreReplicator();
    replicator.setSourceStore(sourceStore);
    replicator.setTargetStore(targetStore);
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:23,代码来源:ContentStoreReplicatorTest.java


示例12: createNewUrl

import org.alfresco.repo.content.filestore.FileContentStore; //导入依赖的package包/类
/**
 * Creates a new content URL.  This must be supported by all
 * stores that are compatible with Alfresco.
 *
 * @return Returns a new and unique content URL
 */
public static String createNewUrl() {
	final Calendar calendar = new GregorianCalendar();
	final int year = calendar.get(Calendar.YEAR);
	final int month = calendar.get(Calendar.MONTH) + 1; // 0-based
	final int day = calendar.get(Calendar.DAY_OF_MONTH);
	final int hour = calendar.get(Calendar.HOUR_OF_DAY);
	final int minute = calendar.get(Calendar.MINUTE);
	// create the URL
	final StringBuffer urlStr = new StringBuffer();
	urlStr.append(FileContentStore.STORE_PROTOCOL)
			.append(ContentStore.PROTOCOL_DELIMITER).append(year)
			.append('/').append(month).append('/').append(day).append('/')
			.append(hour).append('/').append(minute).append('/')
			.append(GUID.generate()).append(".bin");
	
	return urlStr.toString();
}
 
开发者ID:abhinavmishra14,项目名称:alfresco-amazon-s3-content-store-integration,代码行数:24,代码来源:S3ContentStore.java


示例13: exists

import org.alfresco.repo.content.filestore.FileContentStore; //导入依赖的package包/类
/**
 * {@inheritDoc}
 * <p>
 * For {@link #SPOOF_PROTOCOL spoofed} URLs, the URL always exists.
 */
@Override
public boolean exists(String contentUrl)
{
    if (contentUrl.startsWith(FileContentStore.SPOOF_PROTOCOL))
    {
        return true;
    }
    else
    {
        return backingStore.exists(contentUrl);
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:18,代码来源:CachingContentStore.java


示例14: getReader

import org.alfresco.repo.content.filestore.FileContentStore; //导入依赖的package包/类
/**
 * {@inheritDoc}
 * <p>
 * This store handles the {@link FileContentStore#SPOOF_PROTOCOL} so that underlying stores do not need
 * to implement anything <a href="https://issues.alfresco.com/jira/browse/ACE-4516">related to spoofing</a>.
 */
@Override
public ContentReader getReader(String contentUrl)
{
    // Handle the spoofed URL
    if (contentUrl.startsWith(FileContentStore.SPOOF_PROTOCOL))
    {
        return new SpoofedTextContentReader(contentUrl);
    }

    // Use pool of locks - which one is determined by a hash of the URL.
    // This will stop the content from being read/cached multiple times from the backing store
    // when it should only be read once - cached versions should be returned after that.
    ReadLock readLock = readWriteLock(contentUrl).readLock();
    readLock.lock();
    try
    {
        if (cache.contains(contentUrl))
        {
            return cache.getReader(contentUrl);
        }
    }
    catch(CacheMissException e)
    {
        // Fall through to cacheAndRead(url);
    }
    finally
    {
        readLock.unlock();
    }
    
    return cacheAndRead(contentUrl);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:39,代码来源:CachingContentStore.java


示例15: loadData

import org.alfresco.repo.content.filestore.FileContentStore; //导入依赖的package包/类
private void loadData(final int maxCount)
{
    final MutableInt doneCount = new MutableInt(0);
    // Batches of 1000 objects
    RetryingTransactionCallback<Integer> makeNodesCallback = new RetryingTransactionCallback<Integer>()
    {
        public Integer execute() throws Throwable
        {
            for (int i = 0; i < 1000; i++)
            {
                // We don't need to write anything
                String contentUrl = FileContentStore.createNewFileStoreUrl();
                ContentData contentData = new ContentData(contentUrl, MimetypeMap.MIMETYPE_TEXT_PLAIN, 10, "UTF-8");
                nodeHelper.makeNode(contentData);
                
                int count = doneCount.intValue();
                count++;
                doneCount.setValue(count);
                
                // Do some reporting
                if (count % 1000 == 0)
                {
                    System.out.println(String.format("   " + (new Date()) + "Total created: %6d", count));
                }
                
                // Double check for shutdown
                if (vmShutdownListener.isVmShuttingDown())
                {
                    break;
                }
            }
            return maxCount;
        }
    };
    int repetitions = (int) Math.floor((double)maxCount / 1000.0);
    for (int i = 0; i < repetitions; i++)
    {
        transactionService.getRetryingTransactionHelper().doInTransaction(makeNodesCallback);
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:41,代码来源:ContentStoreCleanerScalabilityRunner.java


示例16: before

import org.alfresco.repo.content.filestore.FileContentStore; //导入依赖的package包/类
@Before
public void before() throws Exception
{
    File tempDir = TempFileProvider.getTempDir();
    
    backingStore = new FileContentStore(ctx,
            tempDir.getAbsolutePath() +
            File.separatorChar +
            getName());
    
    cache = new ContentCacheImpl();
    cache.setCacheRoot(TempFileProvider.getLongLifeTempDir("cached_content_test"));
    cache.setMemoryStore(createMemoryStore());
    store = new CachingContentStore(backingStore, cache, false);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:16,代码来源:CachingContentStoreSpringTest.java


示例17: testCacheOnInbound

import org.alfresco.repo.content.filestore.FileContentStore; //导入依赖的package包/类
public void testCacheOnInbound()
{
    store = new CachingContentStore(backingStore, cache, true);
    final String content = "Content for " + getName() + " test.";
    final String contentUrl = FileContentStore.createNewFileStoreUrl();
    
    assertFalse("Content shouldn't be cached yet", cache.contains(contentUrl));
    
    // Write some content using the caching store
    ContentWriter writer = store.getWriter(new ContentContext(null, contentUrl));
    writer.putContent(content);
    
    assertTrue("Cache should contain content after write", cache.contains(contentUrl));
    // Check DIRECTLY with the cache, since a getReader() from the CachingContentStore would result
    // in caching, but we're checking that caching was caused by the write operation.
    String retrievedContent = cache.getReader(contentUrl).getContentString(); 
    assertEquals(content, retrievedContent);
    
    // The content should have been written through to the backing store.
    String fromBackingStore = backingStore.getReader(contentUrl).getContentString();
    assertEquals("Content should be in backing store", content, fromBackingStore);
    
    // Remove the original content from the backing store.
    backingStore.delete(contentUrl);
    assertFalse("Original content should have been deleted", backingStore.exists(contentUrl));
    
    // The cached version is still available
    String contentAfterDelete = store.getReader(contentUrl).getContentString();
    assertEquals(content, contentAfterDelete);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:31,代码来源:CachingContentStoreSpringTest.java


示例18: testQuotaOnOverlimitCacheFile

import org.alfresco.repo.content.filestore.FileContentStore; //导入依赖的package包/类
public void testQuotaOnOverlimitCacheFile()
{
    store = new CachingContentStore(backingStore, cache, true);
    
    final int overLimitSize = 1;
    QuotaManagerStrategy quota = mock(QuotaManagerStrategy.class);
    store.setQuota(quota);
    when(quota.beforeWritingCacheFile(0)).thenReturn(true);
    when(quota.afterWritingCacheFile(overLimitSize)).thenReturn(false);
    
    char[] chars = new char[overLimitSize];
    // Optional step - unnecessary if you're happy with the array being full of \0
    Arrays.fill(chars, 'f');
    final String content = new String(chars);
    final String contentUrl = FileContentStore.createNewFileStoreUrl();
    assertFalse("Content shouldn't be cached yet", cache.contains(contentUrl));
    
    // Write some content using the caching store
    ContentWriter writer = store.getWriter(new ContentContext(null, contentUrl));
    writer.putContent(content);
    
    assertFalse("Overlimit content should be deleted from cache", cache.contains(contentUrl));
    assertFalse("Overlimit content should be deleted from cache", writer.getReader().exists());

    // The content should have been written through to the backing store.
    String fromBackingStore = backingStore.getReader(contentUrl).getContentString();
    assertEquals("Content should be in backing store", content, fromBackingStore);
    assertEquals("Content should be in backing store", overLimitSize, fromBackingStore.length());
    
    // cache writer should still return actual size
    // so that listeners could be executed correctly
    assertEquals("Cache writer should still return actual size", overLimitSize, writer.getSize());
    assertEquals("Cache writer should still return actual size", overLimitSize, writer.getContentData().getSize());
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:35,代码来源:CachingContentStoreSpringTest.java


示例19: writeToCacheWithContentContext

import org.alfresco.repo.content.filestore.FileContentStore; //导入依赖的package包/类
@Test
public void writeToCacheWithContentContext()
{
    // Write through the caching content store - cache during the process.
    final String proposedUrl = FileContentStore.createNewFileStoreUrl();
    ContentWriter writer = store.getWriter(new ContentContext(null, proposedUrl));
    final String content = makeContent();
    writer.putContent(content);
    assertEquals("Writer should have correct URL", proposedUrl, writer.getContentUrl());
    
    ContentReader reader = store.getReader(writer.getContentUrl());
    assertEquals("Reader and writer should have same URLs", writer.getContentUrl(), reader.getContentUrl());
    assertEquals("Reader should get correct content", content, reader.getContentString());
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:15,代码来源:FullTest.java


示例20: getWriterInternal

import org.alfresco.repo.content.filestore.FileContentStore; //导入依赖的package包/类
@Override
protected ContentWriter getWriterInternal(ContentReader existingContentReader, String newContentUrl)
{
    if (newContentUrl == null)
        newContentUrl = FileContentStore.createNewFileStoreUrl() + ".slow";
    
    return new SlowWriter(newContentUrl, existingContentReader);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:9,代码来源:SlowContentStore.java



注:本文中的org.alfresco.repo.content.filestore.FileContentStore类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java IAudioSamples类代码示例发布时间:2022-05-23
下一篇:
Java MarginBorder类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap