当前位置: 首页>>代码示例>>Java>>正文


Java MimetypeMap类代码示例

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


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

示例1: test18AddCustomWebClient

import org.alfresco.repo.content.MimetypeMap; //导入依赖的package包/类
public void test18AddCustomWebClient()
{
    // note: add as demo files - need to re-start Alfresco to see custom web client config / messages 
    logger.info("test add custom web client config");
    
    for (final String tenantDomain : tenants)
    {    
        final String tenantAdminName = tenantService.getDomainUser(AuthenticationUtil.getAdminUserName(), tenantDomain);
        
        TenantUtil.runAsUserTenant(new TenantRunAsWork<Object>()
        {
            public Object doWork() throws Exception
            {
                NodeRef webClientExtFolder = getWebClientExtensionNodeRef(SPACES_STORE);
                
                InputStream is = getClass().getClassLoader().getResourceAsStream("tenant/webclient.properties");
                addContent(webClientExtFolder, "webclient.properties", is, MimetypeMap.MIMETYPE_TEXT_PLAIN);
                
                is = getClass().getClassLoader().getResourceAsStream("tenant/web-client-config-custom.xml");
                addContent(webClientExtFolder, "web-client-config-custom.xml", is, MimetypeMap.MIMETYPE_XML);
                
                return null;
            }
        }, tenantAdminName, tenantDomain);
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:27,代码来源:MultiTDemoTest.java

示例2: testMimetypeSpecificTimeout

import org.alfresco.repo.content.MimetypeMap; //导入依赖的package包/类
/**
 * Tests that delayed metadata extraction times out properly for mimetype-specific limits.
 *
 * @throws Exception
 */
@Test
public void testMimetypeSpecificTimeout() throws Exception
{
    long timeoutMs = 1000;

    MetadataExtracterLimits limits = new MetadataExtracterLimits();
    limits.setTimeoutMs(timeoutMs);
    HashMap<String, MetadataExtracterLimits> mimetypeLimits =
            new HashMap<String, MetadataExtracterLimits>(1);
    mimetypeLimits.put(MimetypeMap.MIMETYPE_TEXT_PLAIN, limits);
    ((MockDelayedMetadataExtracter) getExtracter()).setMimetypeLimits(mimetypeLimits);

    File file = AbstractContentTransformerTest.loadNamedQuickTestFile("quick.txt");

    long startTime = (new Date()).getTime();
    extractFromFile(file, MimetypeMap.MIMETYPE_TEXT_PLAIN);
    long extractionTime = (new Date()).getTime() - startTime;

    assertTrue("Metadata extraction took (" + extractionTime + "ms) " +
            "but should have failed with a timeout at " + timeoutMs + "ms",
            extractionTime < (timeoutMs + 50)); // bit of wiggle room for logging, cleanup, etc.
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:28,代码来源:MetadataExtracterLimitsTest.java

示例3: exportSystem

import org.alfresco.repo.content.MimetypeMap; //导入依赖的package包/类
public FileExportHandle exportSystem(String packageName)
{
    // create a temporary file to hold the system info export
    File tempFile = TempFileProvider.createTempFile("repoExpSystemInfo", ".xml");

    try
    {
        OutputStream outputStream = new FileOutputStream(tempFile);
        systemExporterImporter.exportSystem(outputStream);
    }
    catch(FileNotFoundException e)
    {
        tempFile.delete();
        throw new ExporterException("Failed to create temporary file for holding export of system info");
    }
    
    // return handle onto temp file
    FileExportHandle handle = new FileExportHandle();
    handle.storeRef = null;
    handle.packageName = packageName;
    handle.mimeType = MimetypeMap.MIMETYPE_XML;
    handle.exportFile = tempFile;
    return handle;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:25,代码来源:RepositoryExporterComponent.java

示例4: testRFC822ToText

import org.alfresco.repo.content.MimetypeMap; //导入依赖的package包/类
/**
 * Test transforming a valid eml file to text
 */
public void testRFC822ToText() throws Exception
{
    File emlSourceFile = loadQuickTestFile("eml");
    File txtTargetFile = TempFileProvider.createTempFile("test", ".txt");
    ContentReader reader = new FileContentReader(emlSourceFile);
    reader.setMimetype(MimetypeMap.MIMETYPE_RFC822);
    ContentWriter writer = new FileContentWriter(txtTargetFile);
    writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN);

    transformer.transform(reader, writer);

    ContentReader reader2 = new FileContentReader(txtTargetFile);
    reader2.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN);
    assertTrue(reader2.getContentString().contains(QUICK_EML_CONTENT));
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:19,代码来源:EMLTransformerTest.java

示例5: testTransform

import org.alfresco.repo.content.MimetypeMap; //导入依赖的package包/类
@Test//(expected = AccessDeniedException.class)
public void testTransform() throws Exception
{
    final File file = loadAndAddQuickFileAsManager(testNode, "quick.txt", MimetypeMap.MIMETYPE_TEXT_PLAIN);
    assertNotNull("Failed to load required test file.", file);

    // Set authentication to SiteConsumer.
    AuthenticationUtil.setFullyAuthenticatedUser(testSiteAndMemberInfo.siteManager);
    transactionHelper.doInTransaction(new RetryingTransactionCallback<Void>()
    {
        public Void execute() throws Throwable
        {
            Action action = actionService.createAction(TransformActionExecuter.NAME);
            Map<String, Serializable> map = new HashMap<String, Serializable>();
            map.put(TransformActionExecuter.PARAM_MIME_TYPE, MimetypeMap.MIMETYPE_HTML);
            map.put(TransformActionExecuter.PARAM_DESTINATION_FOLDER, nodeService.getPrimaryParent(testNode)
                    .getParentRef());
            action.setParameterValues(map);

            actionService.executeAction(action, testNode);

            return null;
        }
    });
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:26,代码来源:ActionServiceImpl2Test.java

示例6: onSetUpInTransaction

import org.alfresco.repo.content.MimetypeMap; //导入依赖的package包/类
@Override
protected void onSetUpInTransaction() throws Exception
{
    super.onSetUpInTransaction();

    this.transactionHelper = (RetryingTransactionHelper)this.applicationContext.getBean("retryingTransactionHelper");

    // Create the node used for tests
    this.nodeRef = this.nodeService.createNode(
            this.rootNodeRef,
            ContentModel.ASSOC_CHILDREN,
            QName.createQName("{test}testnode"),
            ContentModel.TYPE_CONTENT).getChildRef();
    this.nodeService.setProperty(
            this.nodeRef,
            ContentModel.PROP_CONTENT,
            new ContentData(null, MimetypeMap.MIMETYPE_TEXT_PLAIN, 0L, null));
    this.folder = this.nodeService.createNode(
            this.rootNodeRef,
            ContentModel.ASSOC_CHILDREN,
            QName.createQName("{test}testFolder"),
            ContentModel.TYPE_FOLDER).getChildRef();
    
    // Register the test executor, if needed
    SleepActionExecuter.registerIfNeeded(applicationContext);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:27,代码来源:ActionServiceImplTest.java

示例7: getContentInfo

import org.alfresco.repo.content.MimetypeMap; //导入依赖的package包/类
/**
    * Returns the basic content info from the request.
    * @param req WebScriptRequest
    * @return BasicContentInfo
    */
   private BasicContentInfo getContentInfo(WebScriptRequest req) {
   	
	String encoding = "UTF-8";
	String contentType = MimetypeMap.MIMETYPE_BINARY;
	
	if (StringUtils.isNotEmpty(req.getContentType()))
	{
		MediaType media = MediaType.parseMediaType(req.getContentType());
		contentType = media.getType()+'/'+media.getSubtype();
		if (media.getCharSet() != null)
		{
			encoding = media.getCharSet().toString();
		}			
	}

       return new ContentInfoImpl(contentType, encoding, -1, Locale.getDefault());
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:23,代码来源:ResourceWebScriptPut.java

示例8: testMediaWikiToHTML

import org.alfresco.repo.content.MimetypeMap; //导入依赖的package包/类
public void testMediaWikiToHTML() throws Exception
{
   File input = TempFileProvider.createTempFile("mediaWikiTest", ".mw");
   FileOutputStream fos = new FileOutputStream(input);
   fos.write(WIKI_TEXT.getBytes());
   fos.close();
   
   File output = TempFileProvider.createTempFile("mediaWikiTest", ".htm");
   
   ContentReader contentReader = new FileContentReader(input);
   contentReader.setMimetype(MimetypeMap.MIMETYPE_TEXT_MEDIAWIKI);
   contentReader.setEncoding("UTF-8");
   
   ContentWriter contentWriter = new FileContentWriter(output);
   contentWriter.setMimetype(MimetypeMap.MIMETYPE_HTML);
   contentWriter.setEncoding("UTF-8");
   
   transformer.transform(contentReader, contentWriter);
   
   String line = null;
   BufferedReader reader = new BufferedReader(new FileReader(output));
   while ((line = reader.readLine()) != null) 
   {
       System.out.println(line);
   }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:27,代码来源:MediaWikiContentTransformerTest.java

示例9: createFreeMarkerNode

import org.alfresco.repo.content.MimetypeMap; //导入依赖的package包/类
private NodeRef createFreeMarkerNode(NodeRef companyHome)
{
    NodeRef fmNode = createContentNode(companyHome, "testFreeMarkerNode");
    nodeService.setProperty(fmNode, ContentModel.PROP_CONTENT, new ContentData(null,
                MimetypeMap.MIMETYPE_TEXT_PLAIN, 0L, null));

    URL url = getClass().getResource(FM_TEMPLATE);
    assertNotNull("The url is null", url);
    File templateFile = new File(url.getFile());
    assertTrue("The template file does not exist", templateFile.exists());

    ContentWriter fmWriter = contentService.getWriter(fmNode, ContentModel.PROP_CONTENT, true);
    fmWriter.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN);
    fmWriter.setEncoding("UTF-8");
    fmWriter.putContent(templateFile);
    return fmNode;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:18,代码来源:RenditionServiceIntegrationTest.java

示例10: isTransformationBlocked

import org.alfresco.repo.content.MimetypeMap; //导入依赖的package包/类
/**
 * There are some conversions that fail, despite the converter believing them possible.
 * This method can be used by subclasses to check if a targetMimetype or source/target
 * Mimetype pair are blocked.
 * 
 * @param sourceMimetype String
 * @param targetMimetype String
 * @return <code>true</code> if the mimetypes are blocked, else <code>false</code>
 */
protected boolean isTransformationBlocked(String sourceMimetype, String targetMimetype)
{
    if (targetMimetype.equals(MimetypeMap.MIMETYPE_XHTML))
    {
        return true;
    }
    else if (targetMimetype.equals(MimetypeMap.MIMETYPE_WORDPERFECT))
    {
        return true;
    }
    else if (targetMimetype.equals(MimetypeMap.MIMETYPE_FLASH))
    {
        return true;
    }
    else
    {
        return false;
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:29,代码来源:OOoContentTransformerHelper.java

示例11: testStaticUrlForm_02

import org.alfresco.repo.content.MimetypeMap; //导入依赖的package包/类
public void testStaticUrlForm_02()
{
    // To URL
    String url = SpoofedTextContentReader.createContentUrl(Locale.ENGLISH, 12345L, 1024L);
    assertTrue(url.startsWith("spoof://{"));
    assertTrue(url.contains("\"locale\":\"en\""));
    assertTrue(url.contains("\"seed\":\"12345\""));
    assertTrue(url.contains("\"size\":\"1024\""));
    assertTrue(url.contains("\"words\":[]"));
    assertTrue(url.endsWith("}"));
    // From Reader
    SpoofedTextContentReader reader = new SpoofedTextContentReader(url);
    assertNotNull(reader.getTextGenerator());
    assertEquals(Locale.ENGLISH, reader.getLocale());
    assertEquals(MimetypeMap.MIMETYPE_TEXT_PLAIN, reader.getMimetype());
    assertEquals("UTF-8", reader.getEncoding());
    assertEquals(12345L, reader.getSeed());
    assertEquals(1024L, reader.getSize());
    assertNotNull(reader.getWords());
    assertEquals(0, reader.getWords().length);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:22,代码来源:SpoofedTextContentReaderTest.java

示例12: testCreateThumbnailInReadonlyMode

import org.alfresco.repo.content.MimetypeMap; //导入依赖的package包/类
public void testCreateThumbnailInReadonlyMode() throws Exception
{
    createUser(USER_ALFRESCO);
    AuthenticationUtil.setFullyAuthenticatedUser(USER_ALFRESCO);
    this.transactionService.setAllowWrite(false);
    
    // do pdfToSWF transformation in read-only
    if (this.contentService.getTransformer(MimetypeMap.MIMETYPE_PDF, MimetypeMap.MIMETYPE_FLASH) != null)
    {
        // in share creation of thumbnail for webpreview is forced
        String url = "/api/node/" + pdfNode.getStoreRef().getProtocol() + "/" + pdfNode.getStoreRef().getIdentifier() + "/" + pdfNode.getId() + "/content/thumbnails/webpreview?c=force";
        
        JSONObject tn = new JSONObject();
        tn.put("thumbnailName", "webpreview");
        
        sendRequest(new GetRequest(url), 200, USER_ALFRESCO);
    }
    
    this.transactionService.setAllowWrite(true);
    
    // Check getAll whilst we are here 
    Response getAllResp = sendRequest(new GetRequest(getThumbnailsURL(jpgNode)), 200);
    JSONArray getArr = new JSONArray(getAllResp.getContentAsString());
    assertNotNull(getArr);
    assertEquals(0, getArr.length());
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:27,代码来源:ThumbnailServiceTest.java

示例13: setUp

import org.alfresco.repo.content.MimetypeMap; //导入依赖的package包/类
@Override
public void setUp() throws Exception
{
    super.setUp();
    extracter = new PdfBoxMetadataExtracter();
    extracter.setDictionaryService(dictionaryService);
    
    MetadataExtracterLimits pdfLimit = new MetadataExtracterLimits();
    pdfLimit.setMaxConcurrentExtractionsCount(MAX_CONCURENT_EXTRACTIONS);
    pdfLimit.setMaxDocumentSizeMB(MAX_DOC_SIZE_MB);
    Map<String,MetadataExtracterLimits> limits = new HashMap<>();
    limits.put(MimetypeMap.MIMETYPE_PDF,pdfLimit);
    
    extracter.setMimetypeLimits(limits);
    extracter.register();
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:17,代码来源:PdfBoxMetadataExtracterTest.java

示例14: isTransformable

import org.alfresco.repo.content.MimetypeMap; //导入依赖的package包/类
@Override
public boolean isTransformable(String sourceMimetype, String targetMimetype, TransformationOptions options)
{
    if (!available)
    {
        return false;
    }

    // Add limited support (so lots of other transforms are not supported)
    // for PDF to PNG.
    if ((MimetypeMap.MIMETYPE_PDF.equals(sourceMimetype) || MimetypeMap.MIMETYPE_APPLICATION_ILLUSTRATOR.equals(sourceMimetype)) &&
        MimetypeMap.MIMETYPE_IMAGE_PNG.equals(targetMimetype))
    {
        return true;
    }

    return false;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:19,代码来源:AlfrescoPdfRendererContentTransformerWorker.java

示例15: testInvokeMultiPartEntity

import org.alfresco.repo.content.MimetypeMap; //导入依赖的package包/类
@Test
public void testInvokeMultiPartEntity() throws IOException
{
    ResourceWithMetadata entityResource = locator.locateEntityResource(api,"multiparttest", HttpMethod.POST);
    assertNotNull(entityResource);
    MultiPartResourceAction.Create<?> resource = (MultiPartResourceAction.Create<?>) entityResource.getResource();

    File file = TempFileProvider.createTempFile("ParamsExtractorTests-", ".txt");
    PrintWriter writer = new PrintWriter(file);
    writer.println("Multipart Mock test2.");
    writer.close();

    MultiPartRequest reqBody = MultiPartBuilder.create()
                .setFileData(new FileData(file.getName(), file, MimetypeMap.MIMETYPE_TEXT_PLAIN))
                .build();

    MockHttpServletRequest mockRequest = new MockHttpServletRequest("POST", "");
    mockRequest.setContent(reqBody.getBody());
    mockRequest.setContentType(reqBody.getContentType());

    String out = writeResponse(helper.processAdditionsToTheResponse(mock(WebScriptResponse.class), api,null, NOT_USED, resource.create(new FormData(mockRequest), NOT_USED, callBack)));
    assertTrue("There must be json output", StringUtils.startsWith(out, "{\"entry\":"));
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:24,代码来源:SerializeTests.java


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