@Override public FacetLabel getDisplayLabel(String value) { Map<String, String> mimetypes = serviceRegistry.getMimetypeService().getDisplaysByMimetype(); String displayName = mimetypes.get(value); return new FacetLabel(value, displayName == null ? value : displayName.trim(), -1); } }
@Override public FacetLabel getDisplayLabel(String value) { Map<String, String> mimetypes = serviceRegistry.getMimetypeService().getDisplaysByMimetype(); String displayName = mimetypes.get(value); return new FacetLabel(value, displayName == null ? value : displayName.trim(), -1); } }
public String getDisplayMimetype() { return services.getMimetypeService().getDisplaysByMimetype().get(getMimetype()); }
public String getDisplayMimetype() { return services.getMimetypeService().getDisplaysByMimetype().get(getMimetype()); }
private String guessEncoding(InputStream in, boolean close) { String encoding = "UTF-8"; try { if (in != null) { Charset charset = services.getMimetypeService().getContentCharsetFinder().getCharset(in, getMimetype()); encoding = charset.name(); } } finally { try { if (close && in != null) { in.close(); } } catch (IOException ioErr) { } } return encoding; }
private String guessEncoding(InputStream in, boolean close) { String encoding = "UTF-8"; try { if (in != null) { Charset charset = services.getMimetypeService().getContentCharsetFinder().getCharset(in, getMimetype()); encoding = charset.name(); } } finally { try { if (close && in != null) { in.close(); } } catch (IOException ioErr) { } } return encoding; }
/** * Guess the mimetype for the given filename - uses the extension to match on system mimetype map */ public void guessMimetype(String filename) { ContentService contentService = services.getContentService(); ContentReader reader = contentService.getReader(nodeRef, property); // MNT-12265 Browser sets a mimetype based on extension of file. But mimeType from browser can be // different as mapped in Alfresco for current extension. Therefore we need to guess a mimetype based on // map in Alfresco String typeByExt = services.getMimetypeService().guessMimetype(filename); if (reader != null && reader.getMimetype() != null && !typeByExt.equals(MimetypeMap.MIMETYPE_BINARY)) { setMimetype(typeByExt); } else { setMimetype(services.getMimetypeService().guessMimetype(filename, reader)); } }
/** * Guess the mimetype for the given filename - uses the extension to match on system mimetype map */ public void guessMimetype(String filename) { ContentService contentService = services.getContentService(); ContentReader reader = contentService.getReader(nodeRef, property); // MNT-12265 Browser sets a mimetype based on extension of file. But mimeType from browser can be // different as mapped in Alfresco for current extension. Therefore we need to guess a mimetype based on // map in Alfresco String typeByExt = services.getMimetypeService().guessMimetype(filename); if (reader != null && reader.getMimetype() != null && !typeByExt.equals(MimetypeMap.MIMETYPE_BINARY)) { setMimetype(typeByExt); } else { setMimetype(services.getMimetypeService().guessMimetype(filename, reader)); } }
/** * Ensures that the temp locations are cleaned out before the tests start */ @Override protected void setUp() throws Exception { // Grab a suitably configured context ctx = MiscContextTestSuite.getMinimalContext(); // Grab other useful beans serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY); mimetypeService = serviceRegistry.getMimetypeService(); transformerDebug = (TransformerDebug) ctx.getBean("transformerDebug"); transformerConfig = (TransformerConfig) ctx.getBean("transformerConfig"); // perform a little cleaning up long now = System.currentTimeMillis(); TempFileProvider.TempFileCleanerJob.removeFiles(now); }
protected Map<QName, Serializable> extractFromMimetype() throws Exception { Map<QName, Serializable> properties = new HashMap<QName, Serializable>(); // attempt to get a source file for each mimetype File sourceFile = AbstractContentTransformerTest.loadQuickTestFile("doc"); if (sourceFile == null) { throw new FileNotFoundException("No quick.doc file found for test"); } // construct a reader onto the source file ContentReader sourceReader = new FileContentReader(sourceFile); sourceReader.setMimetype(MimetypeMap.MIMETYPE_WORD); OpenOfficeMetadataWorker worker = (OpenOfficeMetadataWorker) ctx.getBean("extracter.worker.JodConverter"); Set<String> supportedTypes = new HashSet<String>(); supportedTypes.add(MimetypeMap.MIMETYPE_WORD); JodConverterMetadataExtracter extracter = new JodConverterMetadataExtracter(supportedTypes); extracter.setMimetypeService(serviceRegistry.getMimetypeService()); extracter.setDictionaryService(serviceRegistry.getDictionaryService()); extracter.setWorker(worker); extracter.init(); extracter.extract(sourceReader, properties); return properties; } }
MimetypeService mimetypeService = serviceRegistry.getMimetypeService(); TransformerDebug transformerDebug = (TransformerDebug) ctx.getBean("transformerDebug"); TransformerConfig transformerConfig = (TransformerConfig) ctx.getBean("transformerConfig");
transformCommand.setErrorCodes("1, 2"); worker.setTransformCommand(transformCommand); worker.setMimetypeService(serviceRegistry.getMimetypeService()); transformer.setMimetypeService(serviceRegistry.getMimetypeService()); transformer.setTransformerDebug(transformerDebug); transformer.setTransformerConfig(transformerConfig);
public void setUp() { ctx = ApplicationContextHelper.getApplicationContext(); serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY); nodeService = serviceRegistry.getNodeService(); searchService = serviceRegistry.getSearchService(); dictionaryService = serviceRegistry.getDictionaryService(); contentService = serviceRegistry.getContentService(); authenticationService = (MutableAuthenticationService) ctx.getBean("authenticationService"); authenticationComponent = (AuthenticationComponent) ctx.getBean("authenticationComponent"); permissionService = serviceRegistry.getPermissionService(); mimetypeService = serviceRegistry.getMimetypeService(); namespaceService = serviceRegistry.getNamespaceService(); transactionService = serviceRegistry.getTransactionService(); authenticationComponent.setSystemUserAsCurrentUser(); StoreRef storeRef = nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "Test_" + System.currentTimeMillis()); rootNodeRef = nodeService.getRootNode(storeRef); }
/** * Create a new File (cm:content) node as a child of this node. * <p> * Once created the file should have content set using the <code>content</code> property. * * Beware: Any unsaved property changes will be lost when this is called. To preserve property changes call {@link #save()} first. * * @param name Name of the file to create * @param type Type of the file to create (if null, defaults to ContentModel.TYPE_CONTENT) * * @return Newly created Node or null if failed to create. */ public ScriptNode createFile(String name, String type) { ParameterCheck.mandatoryString("Node Name", name); FileInfo fileInfo = this.services.getFileFolderService().create( this.nodeRef, name, type == null ? ContentModel.TYPE_CONTENT : createQName(type)); reset(); ScriptNode file = newInstance(fileInfo.getNodeRef(), this.services, this.scope); file.setMimetype(this.services.getMimetypeService().guessMimetype(name)); return file; }
/** * Create a new File (cm:content) node as a child of this node. * <p> * Once created the file should have content set using the <code>content</code> property. * * Beware: Any unsaved property changes will be lost when this is called. To preserve property changes call {@link #save()} first. * * @param name Name of the file to create * @param type Type of the file to create (if null, defaults to ContentModel.TYPE_CONTENT) * * @return Newly created Node or null if failed to create. */ public ScriptNode createFile(String name, String type) { ParameterCheck.mandatoryString("Node Name", name); FileInfo fileInfo = this.services.getFileFolderService().create( this.nodeRef, name, type == null ? ContentModel.TYPE_CONTENT : createQName(type)); reset(); ScriptNode file = newInstance(fileInfo.getNodeRef(), this.services, this.scope); file.setMimetype(this.services.getMimetypeService().guessMimetype(name)); return file; }
@Before public void setUp() throws Exception { ApplicationContext ctx = ApplicationContextHelper.getApplicationContext(); serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY); mimetypeService = serviceRegistry.getMimetypeService(); transformerDebug = (TransformerDebug) ctx.getBean("transformerDebug"); transformerConfig = (TransformerConfig) ctx.getBean("transformerConfig"); registry = (ContentTransformerRegistry) ctx.getBean("contentTransformerRegistry"); transactionService = serviceRegistry.getTransactionService(); repositoryHelper = (Repository) ctx.getBean("repositoryHelper"); nodeService = serviceRegistry.getNodeService(); contentService = serviceRegistry.getContentService(); assertNotNull("MimetypeMap not present", this.mimetypeService); assertNotNull("ServiceRegistry not present", serviceRegistry); assertNotNull("TransformerDebug not present", transformerDebug); assertNotNull("TransformerConfig not present", transformerConfig); assertNotNull("transactionService not present", transactionService); assertNotNull("repositoryHelper not present", repositoryHelper); assertNotNull("nodeService not present", nodeService); assertNotNull("contentService not present", contentService); }
mimetype = this.services.getMimetypeService().guessMimetype(fileName);
mimetype = this.services.getMimetypeService().guessMimetype(fileName);
MimetypeService mimetypeService = getServiceRegistry().getMimetypeService();
MimetypeService mimetypeService = getServiceRegistry().getMimetypeService();