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);
mimeType = MimeTypes.getMimeType(node.getName(), MimeTypes.APPLICATION_OCTET_STREAM); needsDir = !MimeTypes.matches(node.getName(), mimeType, MimeTypes.APPLICATION_OCTET_STREAM); needsDir = !"utf-8".equals(encoding) || MimeTypes.isBinary(mimeType);
/** * Checks if this file has binary content. It does not actually read the * file data but calls {@link MimeTypes#isBinary(String)} with the content * type of the work file. * @return {@code true} if this is binary */ public boolean isBinary() { return MimeTypes.isBinary(getContentType()); }
/** * 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); }
private boolean getRemoteBinaryType(VaultFile remoteFile, VaultFileCopy copy) { // check if binary boolean remoteBT = MimeTypes.isBinary(remoteFile.getContentType()); if (copy != null && remoteBT != copy.isBinary()) { parent.getContext().printMessage(this, "Remote Binary type differs from actual data. Content Type: " + remoteFile.getContentType() + " Data is binary: " + copy.isBinary() + ". Using data type."); remoteBT = copy.isBinary(); } return remoteBT; }
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);
private boolean equalsToRemote(VaultFile remoteFile) throws VltException { MetaFile tmpFile = getTmpFile(); // copy file byte[] lineFeed = MimeTypes.isBinary(remoteFile.getContentType()) ? null : LineOutputStream.LS_NATIVE; VaultFileCopy copy; File temp = null; try { temp = tmpFile.openTempFile(); copy = VaultFileCopy.copy(remoteFile, temp, lineFeed); } catch (IOException e) { throw exception("Error while copying files.", e); } finally { if (tmpFile != null) { try { tmpFile.closeTempFile(true); } catch (IOException e) { // ignore } } } // if md5 is equal, no update VltEntryInfo base = entry.base(); return copy.getMd5().equals(base.getMd5()); }
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; }
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; }
byte[] lineFeed = MimeTypes.isBinary(remoteFile.getContentType()) ? null : LineOutputStream.LS_NATIVE;