/** * Retrieve the mimetype for the given extension or name * @param name the name * @return the mimetype or {@code null} */ public static String getMimeType(String name) { return getMimeType(name, null); }
return false; } else if (name.equals(JcrConstants.JCR_MIMETYPE)) { String expected = MimeTypes.getMimeType(root.getName(), MimeTypes.APPLICATION_OCTET_STREAM); return !expected.equals(prop.getString()); } else if (name.equals(JcrConstants.JCR_ENCODING)) { if ("utf-8".equals(prop.getString())) { String mimeType = MimeTypes.getMimeType(root.getName(), MimeTypes.APPLICATION_OCTET_STREAM); return MimeTypes.isBinary(mimeType);
if (mimeType == null) { mimeType = Text.getName(a.getRelativePath(), '.'); mimeType = MimeTypes.getMimeType(mimeType, MimeTypes.APPLICATION_OCTET_STREAM);
if (mimeType == null) { mimeType = Text.getName(artifact.getRelativePath(), '.'); mimeType = MimeTypes.getMimeType(mimeType, MimeTypes.APPLICATION_OCTET_STREAM);
public boolean revertConflict(File work) throws IOException { File dir = work.getParentFile(); XmlEntryInfo mine = (XmlEntryInfo) mine(); XmlEntryInfo theirs = (XmlEntryInfo) theirs(); XmlEntryInfo base = (XmlEntryInfo) base(); File fileMine = new File(dir, mine.getName()); if (!fileMine.exists()) { return false; } // copy and delete files FileUtils.copyFile(fileMine, work); fileMine.delete(); new File(dir, theirs.getName()).delete(); new File(dir, base.getName()).delete(); // remove infos remove(mine.getType()); remove(theirs.getType()); base.setName(null); // hack: fix content type if it was lost if (mine.getContentType() == null && base.getContentType() == null) { VltEntryInfo workInfo = work(); if (workInfo.getContentType() == null) { workInfo.setContentType(MimeTypes.getMimeType(work.getName())); } base.setContentType(workInfo.getContentType()); } return true; }
mimeType = MimeTypes.getMimeType(node.getName(), MimeTypes.APPLICATION_OCTET_STREAM);
private FileAction doAdd(boolean force) throws VltException { assert entry == null; entry = parent.getEntries().update(getName(), null, null); VltEntryInfo work = entry.create(VltEntryInfo.Type.WORK); try { work.update(file, true); } catch (IOException e) { throw exception("Error while adding file", e); } String contentType = MimeTypes.getMimeType(file.getName(), MimeTypes.APPLICATION_OCTET_STREAM); work.setContentType(contentType); entry.put(work); return FileAction.ADDED; }