/** * Tells whether this file is binary or textual. * The result will depend on the value of the file {@link #getMimeType() mime type}. * * @return <span class="javakeyword">true</span> if binary */ public boolean isBinary() { return SVNProperty.isBinaryMimeType(myMimeType); }
protected void categorizeProperties(Map original, Map regular, Map entry, Map wc) { if (original == null) { return; } for(Iterator propNames = original.keySet().iterator(); propNames.hasNext();) { String name = (String) propNames.next(); if (SVNProperty.isRegularProperty(name) && regular != null) { regular.put(name, original.get(name)); } else if (SVNProperty.isEntryProperty(name) && entry != null) { entry.put(name, original.get(name)); } else if (SVNProperty.isWorkingCopyProperty(name) && wc != null) { wc.put(name, original.get(name)); } } }
public static boolean propNeedsTranslation(String propertyName) { return SVNProperty.isSVNProperty(propertyName); }
/** * Checks if a property is regular. * * <p/> * A property is considered to be regular if it is not <span class="javakeyword">null</span> and * does not start neither with {@link #SVN_WC_PREFIX} nor with {@link #SVN_ENTRY_PREFIX}. * * @param name a property name * @return <span class="javakeyword">true</span> if regular, otherwise * <span class="javakeyword">false</span> */ public static boolean isRegularProperty(String name) { if (name == null) { return false; } else if (isWorkingCopyProperty(name) || isEntryProperty(name)) { return false; } else { return true; } }
public void changeFileProperty(String path, String propertyName, SVNPropertyValue propertyValue) throws SVNException { FileBaton fb = fileBaton; if (fb.skip) { return; } if (SVNProperty.isWorkingCopyProperty(propertyName)) { return; } else if (SVNProperty.isRegularProperty(propertyName)) { fb.hasPropChanges = true; } fb.propChanges.put(propertyName, propertyValue); }
public static SVNPropertyValue getProperty(SVNWCAccess access, File path, String propName) throws SVNException { SVNEntry entry = access.getEntry(path, false); if (entry == null) { return null; } String[] cachableProperties = entry.getCachableProperties(); if (cachableProperties != null && contains(cachableProperties, propName)) { String[] presentProperties = entry.getPresentProperties(); if (presentProperties == null || !contains(presentProperties, propName)) { return null; } if (SVNProperty.isBooleanProperty(propName)) { return SVNProperty.getValueOfBooleanProperty(propName); } } if (SVNProperty.isWorkingCopyProperty(propName)) { return getWCProperty(access, path, propName); } else if (SVNProperty.isEntryProperty(propName)) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.BAD_PROP_KIND, "Property ''{0}'' is an entry property", propName); SVNErrorManager.error(err, SVNLogType.DEFAULT); } SVNAdminArea dir = entry.getKind() == SVNNodeKind.DIR ? access.retrieve(path) : access.retrieve(path.getParentFile()); return dir.getProperties(entry.getName()).getPropertyValue(propName); }
public static void addProperties(SVNAdminArea dir, String fileName, Map properties, boolean base, SVNLog log) throws SVNException { if (properties == null || properties.isEmpty()) { return; } Map regularProps = new HashMap(); Map entryProps = new HashMap(); Map wcProps = new HashMap(); for (Iterator names = properties.keySet().iterator(); names.hasNext();) { String propName = (String) names.next(); String propValue = (String) properties.get(propName); if (SVNProperty.isEntryProperty(propName)) { entryProps.put(SVNProperty.shortPropertyName(propName), propValue); } else if (SVNProperty.isWorkingCopyProperty(propName)) { wcProps.put(propName, propValue); } else { regularProps.put(propName, propValue); } } SVNVersionedProperties props = base ? dir.getBaseProperties(fileName) : dir.getProperties(fileName); props.removeAll(); for (Iterator propNames = regularProps.keySet().iterator(); propNames.hasNext();) { String propName = (String) propNames.next(); String propValue = (String) regularProps.get(propName); props.setPropertyValue(propName, propValue); } dir.saveVersionedProperties(log, false); log.logChangedEntryProperties(fileName, entryProps); log.logChangedWCProperties(fileName, wcProps); }
public String getPropertyValue(String name) throws SVNException { if (getPropertiesMap() != null && getPropertiesMap().containsKey(name)) { return (String) getPropertiesMap().get(name); } SVNEntry entry = myAdminArea.getEntry(myEntryName, true); if (entry != null) { String[] cachableProps = entry.getCachableProperties(); if (cachableProps != null && getIndex(cachableProps, name) >= 0) { String[] presentProps = entry.getPresentProperties(); if (presentProps == null || getIndex(presentProps, name) < 0) { return null; } if (SVNProperty.isBooleanProperty(name)) { return SVNProperty.getValueOfBooleanProperty(name); } } } Map props = loadProperties(); if (!isEmpty()) { return (String)props.get(name); } return null; }
public static void setProperty(SVNWCAccess access, File path, String propName, String propValue, boolean skipChecks) throws SVNException { if (SVNProperty.isWorkingCopyProperty(propName)) { setWCProperty(access, path, propName, propValue, true); return; } else if (SVNProperty.isEntryProperty(propName)) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.BAD_PROP_KIND, "Property ''{0}'' is an entry property", propName); SVNErrorManager.error(err); SVNFileUtil.setExecutable(path, false); } else { propValue = SVNProperty.getValueOfBooleanProperty(propName); SVNFileUtil.setExecutable(path, true); SVNFileUtil.setReadonly(path, false); } else { propValue = SVNProperty.getValueOfBooleanProperty(propName); Map command = new HashMap(); command.put(SVNLog.NAME_ATTR, entry.getName()); command.put(SVNProperty.shortPropertyName(SVNProperty.TEXT_TIME), null); log.addCommand(SVNLog.MODIFY_ENTRY, command, false);
public void logTweakEntry(String name, String newURL, long newRevision) throws SVNException { SVNProperties attributes = new SVNProperties(); attributes.put(SVNProperty.shortPropertyName(SVNProperty.KIND), SVNProperty.KIND_FILE); attributes.put(SVNProperty.shortPropertyName(SVNProperty.REVISION), Long.toString(newRevision)); attributes.put(SVNProperty.shortPropertyName(SVNProperty.DELETED), Boolean.FALSE.toString()); attributes.put(SVNProperty.shortPropertyName(SVNProperty.ABSENT), Boolean.FALSE.toString()); attributes.put(SVNProperty.shortPropertyName(SVNProperty.WORKING_SIZE), Long.toString(SVNProperty.WORKING_SIZE_UNKNOWN)); attributes.put(SVNProperty.shortPropertyName(SVNProperty.TEXT_TIME), SVNDate.NULL.format()); if (newURL != null) { attributes.put(SVNProperty.shortPropertyName(SVNProperty.URL), newURL); } logChangedEntryProperties(name, attributes); }
public boolean hasPropModifications(String name) throws SVNException { SVNEntry entry = getEntry(name, true); if (entry != null) { Map entryAttrs = entry.asMap(); return SVNProperty.booleanValue((String)entryAttrs.get(SVNProperty.HAS_PROP_MODS)); } return false; }
public static void validateProperty(String propertyName, SVNPropertyValue propertyValue) throws SVNException { if (!SVNProperty.isRegularProperty(propertyName)) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.REPOS_BAD_ARGS, "Storage of non-regular property ''{0}'' is disallowed through the repository interface, and could indicate a bug in your client", propertyName); SVNErrorManager.error(err, SVNLogType.FSFS); } if (SVNProperty.isSVNProperty(propertyName) && propertyValue != null) { if (SVNRevisionProperty.DATE.equals(propertyName)) { try { SVNDate.parseDateString(propertyValue.getString()); } catch (SVNException svne) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.BAD_PROPERTY_VALUE); SVNErrorManager.error(err, SVNLogType.FSFS); } } } }
public static Map computeAutoProperties(ISVNOptions options, File file) { Map properties = options.applyAutoProperties(file, null); if (!properties.containsKey(SVNProperty.MIME_TYPE)) { String mimeType = SVNFileUtil.detectMimeType(file); if (mimeType != null) { properties.put(SVNProperty.MIME_TYPE, mimeType); } } if (SVNProperty.isBinaryMimeType((String) properties.get(SVNProperty.MIME_TYPE))) { properties.remove(SVNProperty.EOL_STYLE); } if (!properties.containsKey(SVNProperty.EXECUTABLE)) { if (SVNFileUtil.isExecutable(file)) { properties.put(SVNProperty.EXECUTABLE, SVNProperty.getValueOfBooleanProperty(SVNProperty.EXECUTABLE)); } } return properties; }
/** * Says if the given MIME-type corresponds to a binary (non-textual) type. * * @param mimeType a value of a file {@link #MIME_TYPE} property * @return <span class="javakeyword">true</span> if <code>mimeType</code> * is not a text type * @see #isTextMimeType(String) */ public static boolean isBinaryMimeType(String mimeType) { return !isTextMimeType(mimeType); }
public void changeDirProperty(String name, SVNPropertyValue value) throws SVNException { if (SVNProperty.isRegularProperty(name)) { if (myCurrentDirSummarize.myType != SVNStatusType.STATUS_ADDED) { myCurrentDirSummarize.myPropChanged = true; } } }
protected void checkBooleanProperty(String name, SVNPropertyValue value) throws SVNException { if (!SVNProperty.isBooleanProperty(name)) { return; } String stringValue = value.getString().trim(); if ("".equals(stringValue) || "off".equalsIgnoreCase(stringValue) || "no".equalsIgnoreCase(stringValue) || "false".equalsIgnoreCase(stringValue)) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.BAD_PROPERTY_VALUE, "To turn off the {0} property, use ''svn propdel'';\n" + "setting the property to ''{1}'' will not turn it off.", new Object[]{name, value}); getSVNEnvironment().handleWarning(err, new SVNErrorCode[]{SVNErrorCode.BAD_PROPERTY_VALUE}, getSVNEnvironment().isQuiet()); } } }
private void addFile(File path, SVNFileType type, SVNAdminArea dir) throws SVNException { SVNWCManager.add(path, dir, null, SVNRevision.UNDEFINED); String mimeType = null; if (type == SVNFileType.SYMLINK) { SVNPropertiesManager.setProperty(dir.getWCAccess(), path, SVNProperty.SPECIAL, SVNProperty.getValueOfBooleanProperty(SVNProperty.SPECIAL), false); } else { Map props = SVNPropertiesManager.computeAutoProperties(getOptions(), path); for (Iterator names = props.keySet().iterator(); names.hasNext();) { String propName = (String) names.next(); String propValue = (String) props.get(propName); SVNPropertiesManager.setProperty(dir.getWCAccess(), path, propName, propValue, false); } mimeType = (String) props.get(SVNProperty.MIME_TYPE); } SVNEvent event = SVNEventFactory.createAddedEvent(dir, path.getName(), SVNNodeKind.FILE, mimeType); dispatchEvent(event); }
private void setAttribute(String name, Object value) { if (SVNProperty.ABSENT.equals(name)) { setAbsent(SVNProperty.booleanValue((String) value)); } else if (SVNProperty.CACHABLE_PROPS.equals(name)) { if (value instanceof String) { setCommittedDate((String) value); } else if (SVNProperty.COMMITTED_REVISION.equals(name)) { setCommittedRevision(SVNProperty.longValue((String) value)); } else if (SVNProperty.CONFLICT_NEW.equals(name)) { setConflictNew((String) value); setConflictWorking((String) value); } else if (SVNProperty.COPIED.equals(name)) { setCopied(SVNProperty.booleanValue((String) value)); } else if (SVNProperty.COPYFROM_REVISION.equals(name)) { setCopyFromRevision(SVNProperty.longValue((String) value)); } else if (SVNProperty.COPYFROM_URL.equals(name)) { setCopyFromURL((String) value); } else if (SVNProperty.DELETED.equals(name)) { setDeleted(SVNProperty.booleanValue((String) value)); } else if (SVNProperty.DEPTH.equals(name)) { SVNDepth depth = null; setExternalFileRevision((SVNRevision) value); } else if (SVNProperty.HAS_PROP_MODS.equals(name)) { setHasPropertiesModifications(SVNProperty.booleanValue((String) value)); } else if (SVNProperty.HAS_PROPS.equals(name)) { setHasProperties(SVNProperty.booleanValue((String) value)); } else if (SVNProperty.INCOMPLETE.equals(name)) {
public static void checkPropertyName(String propertyName, SVNPropertyValue propertyValue) throws SVNException { if (SVNRevisionProperty.isRevisionProperty(propertyName)) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.CLIENT_PROPERTY_NAME, "Revision property ''{0}'' not allowed in this context", propertyName); SVNErrorManager.error(err, SVNLogType.WC); } if (propertyValue != null && !SVNPropertiesManager.isValidPropertyName(propertyName)) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.CLIENT_PROPERTY_NAME, "Bad property name: ''{0}''", propertyName); SVNErrorManager.error(err, SVNLogType.WC); } if (SVNProperty.isWorkingCopyProperty(propertyName)) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.CLIENT_PROPERTY_NAME, "''{0}'' is a wcprop, thus not accessible to clients", propertyName); SVNErrorManager.error(err, SVNLogType.WC); } }
public static SVNPropertyValue getProperty(SVNWCAccess access, File path, String propName) throws SVNException { SVNEntry entry = access.getEntry(path, false); if (entry == null) { return null; } String[] cachableProperties = entry.getCachableProperties(); if (cachableProperties != null && contains(cachableProperties, propName)) { String[] presentProperties = entry.getPresentProperties(); if (presentProperties == null || !contains(presentProperties, propName)) { return null; } if (SVNProperty.isBooleanProperty(propName)) { return SVNProperty.getValueOfBooleanProperty(propName); } } if (SVNProperty.isWorkingCopyProperty(propName)) { return getWCProperty(access, path, propName); } else if (SVNProperty.isEntryProperty(propName)) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.BAD_PROP_KIND, "Property ''{0}'' is an entry property", propName); SVNErrorManager.error(err, SVNLogType.DEFAULT); } SVNAdminArea dir = entry.getKind() == SVNNodeKind.DIR ? access.retrieve(path) : access.retrieve(path.getParentFile()); return dir.getProperties(entry.getName()).getPropertyValue(propName); }