Usages of

com.microsoft.tfs.core.clients.versioncontrol.soapextensions.Item.getPropertyValues()
private void createBlob( final ObjectInserter repositoryInserter, final Map<CommitTreePath, Map<CommitTreePath, CommitTreeEntry>> treeHierarchy, final ChangesetCommitItemReader previousChangesetCommitReader, final Item item, final TaskProgressMonitor progressMonitor) throws Exception { Check.notNull(repositoryInserter, "repositoryInserter"); //$NON-NLS-1$ Check.notNull(treeHierarchy, "treeHierarchy"); //$NON-NLS-1$ Check.notNull(previousChangesetCommitReader, "previousChangesetCommitReader"); //$NON-NLS-1$ Check.notNull(item, "item"); //$NON-NLS-1$ Check.notNull(progressMonitor, "progressMonitor"); //$NON-NLS-1$ if (item.getItemType() == ItemType.FOLDER) { return; } File tempFile = null; InputStream tempInputStream = null; ObjectId blobID = null; try { blobID = previousChangesetCommitReader.getFileObjectId(item.getServerItem(), item.getChangeSetID()); if (blobID == null || ObjectId.equals(blobID, ObjectId.zeroId())) { tempFile = File.createTempFile(GitTFConstants.GIT_TF_NAME, null, tempDir); try { versionControlService.downloadFile(item, tempFile.getAbsolutePath()); } catch (VersionControlException e) { // if the user is denied read permissions on the file an // exception will be thrown here. final String itemName = item.getServerItem() == null ? "" : item.getServerItem(); //$NON-NLS-1$ progressMonitor.displayWarning(Messages.formatString( "CreateCommitForChangesetVersionSpecTask.NoContentDueToPermissionOrDestroyFormat", //$NON-NLS-1$ itemName)); log.error(e); return; } if (tempFile.exists()) { tempInputStream = new FileInputStream(tempFile); blobID = repositoryInserter.insert(OBJ_BLOB, tempFile.length(), tempInputStream); } else { blobID = ObjectId.zeroId(); } } FileMode fileMode = FileMode.REGULAR_FILE; /* handle executable files */ if (item.getPropertyValues() != null) { if (PropertyConstants.EXECUTABLE_ENABLED_VALUE.equals(PropertyUtils.selectMatching( item.getPropertyValues(), PropertyConstants.EXECUTABLE_KEY))) { fileMode = FileMode.EXECUTABLE_FILE; } } createBlob(repositoryInserter, treeHierarchy, item.getServerItem(), blobID, fileMode, progressMonitor); } finally { if (tempInputStream != null) { tempInputStream.close(); } if (tempFile != null) { tempFile.delete(); } } }
private void displayProperties(final ItemSet[] items) { for (final ItemSet itemSet : items) { for (final Item item : itemSet.getItems()) { boolean propertyWritten = false; BasicPrinter.printSeparator(getDisplay(), '-'); // item getDisplay().printLine(MessageFormat.format( Messages.getString("CommandProperty.AColonBFormat"), //$NON-NLS-1$ Messages.getString("CommandProperty.ServerItem"), //$NON-NLS-1$ item.getServerItem())); // now write each of the properties if (item.getPropertyValues() != null) { for (final PropertyValue property : item.getPropertyValues()) { propertyWritten = true; getDisplay().printLine(MessageFormat.format( Messages.getString("CommandProperty.AColonBFormat"), //$NON-NLS-1$ Messages.getString("CommandProperty.Name"), //$NON-NLS-1$ property.getPropertyName())); final String valueString; if (property.getPropertyValue() == null) { valueString = Messages.getString("CommandProperty.NullValue"); //$NON-NLS-1$ } else if ((new byte[0]).getClass().equals(property.getPropertyType())) { valueString = Messages.getString("CommandProperty.BinaryValue"); //$NON-NLS-1$ } else { valueString = property.getPropertyValue().toString(); } getDisplay().printLine(MessageFormat.format( Messages.getString("CommandProperty.AColonBFormat"), //$NON-NLS-1$ Messages.getString("CommandProperty.Value"), //$NON-NLS-1$ valueString)); getDisplay().printLine(""); //$NON-NLS-1$ } } if (!propertyWritten) { getDisplay().printLine(Messages.getString("CommandProperty.NoPropertiesOnItem")); //$NON-NLS-1$ getDisplay().printLine(""); //$NON-NLS-1$ } } } }
private void createBlob( final ObjectInserter repositoryInserter, final Map<CommitTreePath, Map<CommitTreePath, CommitTreeEntry>> treeHierarchy, final ChangesetCommitItemReader previousChangesetCommitReader, final Item item, final TaskProgressMonitor progressMonitor) throws Exception { Check.notNull(repositoryInserter, "repositoryInserter"); //$NON-NLS-1$ Check.notNull(treeHierarchy, "treeHierarchy"); //$NON-NLS-1$ Check.notNull(previousChangesetCommitReader, "previousChangesetCommitReader"); //$NON-NLS-1$ Check.notNull(item, "item"); //$NON-NLS-1$ Check.notNull(progressMonitor, "progressMonitor"); //$NON-NLS-1$ if (item.getItemType() == ItemType.FOLDER) { return; } File tempFile = null; InputStream tempInputStream = null; ObjectId blobID = null; try { blobID = previousChangesetCommitReader.getFileObjectId(item.getServerItem(), item.getChangeSetID()); if (blobID == null || ObjectId.equals(blobID, ObjectId.zeroId())) { tempFile = File.createTempFile(GitTFConstants.GIT_TF_NAME, null, tempDir); try { versionControlService.downloadFile(item, tempFile.getAbsolutePath()); } catch (VersionControlException e) { // if the user is denied read permissions on the file an // exception will be thrown here. final String itemName = item.getServerItem() == null ? "" : item.getServerItem(); //$NON-NLS-1$ progressMonitor.displayWarning( Messages.formatString( "CreateCommitForChangesetVersionSpecTask.NoContentDueToPermissionOrDestroyFormat", //$NON-NLS-1$ itemName)); log.error(e); return; } catch (Throwable e) { /* * A workaround for unexpected TFS server errors. Aged * servers with long history might have some items corrupted * in some change sets and return incorrect HTTP response to * the download request. In this case we'd better suppress * the error and assume that the file does not exist. The * next change set that contains this file will commit it * into the repository. It seems to better to miss something * in the file's history log rather than to fail cloning the * repository entirely. */ // TODO: We should make this behavior optional since it's a // bit dangerous. If the file download fails in its last // change set the file will be marked as deleted in the // repository. if (e instanceof IOException) { throw (Exception) e; } else { final String itemName = item.getServerItem() == null ? "???" : item.getServerItem(); //$NON-NLS-1$ final String changeSetID = item.getChangeSetID() == 0 ? "???" //$NON-NLS-1$ : Integer.toString(item.getChangeSetID()); final String checkinDate = item.getCheckinDate() == null ? "???" //$NON-NLS-1$ : item.getCheckinDate().toString(); final String message = Messages.formatString( "CreateCommitForChangesetVersionSpecTask.UnexpectedErrorFormat", //$NON-NLS-1$ itemName, changeSetID, checkinDate); progressMonitor.displayWarning(message); progressMonitor.displayWarning(e.getMessage()); progressMonitor.displayWarning( Messages.getString("CreateCommitForChangesetVersionSpecTask.SeeLog")); //$NON-NLS-1$ log.warn(message); log.error(e); } } if (tempFile.exists()) { tempInputStream = new FileInputStream(tempFile); blobID = repositoryInserter.insert(OBJ_BLOB, tempFile.length(), tempInputStream); } else { blobID = ObjectId.zeroId(); } } FileMode fileMode = FileMode.REGULAR_FILE; /* handle executable files */ if (item.getPropertyValues() != null) { if (PropertyConstants.EXECUTABLE_ENABLED_VALUE.equals( PropertyUtils.selectMatching(item.getPropertyValues(), PropertyConstants.EXECUTABLE_KEY))) { fileMode = FileMode.EXECUTABLE_FILE; } } createBlob(repositoryInserter, treeHierarchy, item.getServerItem(), blobID, fileMode, progressMonitor); } finally { if (tempInputStream != null) { tempInputStream.close(); } if (tempFile != null) { tempFile.delete(); } } }
private void createBlob( final ObjectInserter repositoryInserter, final Map<CommitTreePath, Map<CommitTreePath, CommitTreeEntry>> treeHierarchy, final ChangesetCommitItemReader previousChangesetCommitReader, final Item item, final TaskProgressMonitor progressMonitor) throws Exception { Check.notNull(repositoryInserter, "repositoryInserter"); //$NON-NLS-1$ Check.notNull(treeHierarchy, "treeHierarchy"); //$NON-NLS-1$ Check.notNull(previousChangesetCommitReader, "previousChangesetCommitReader"); //$NON-NLS-1$ Check.notNull(item, "item"); //$NON-NLS-1$ Check.notNull(progressMonitor, "progressMonitor"); //$NON-NLS-1$ if (item.getItemType() == ItemType.FOLDER) { return; } File tempFile = null; InputStream tempInputStream = null; ObjectId blobID = null; try { blobID = previousChangesetCommitReader.getFileObjectId(item.getServerItem(), item.getChangeSetID()); if (blobID == null || ObjectId.equals(blobID, ObjectId.zeroId())) { tempFile = File.createTempFile(GitTFConstants.GIT_TF_NAME, null, tempDir); try { versionControlService.downloadFile(item, tempFile.getAbsolutePath()); } catch (VersionControlException e) { // if the user is denied read permissions on the file an // exception will be thrown here. String itemName = item.getServerItem() == null ? "" : item.getServerItem(); //$NON-NLS-1$ progressMonitor.displayWarning(Messages.formatString( "CreateCommitForChangesetVersionSpecTask.NoContentDueToPermissionOrDestroyFormat", //$NON-NLS-1$ itemName)); log.error(e); return; } if (tempFile.exists()) { tempInputStream = new FileInputStream(tempFile); blobID = repositoryInserter.insert(OBJ_BLOB, tempFile.length(), tempInputStream); } else { blobID = ObjectId.zeroId(); } } FileMode fileMode; /* handle executable files */ if (item.getPropertyValues() != null && PropertyConstants.EXECUTABLE_ENABLED_VALUE.equals(PropertyUtils.selectMatching( item.getPropertyValues(), PropertyConstants.EXECUTABLE_KEY))) { fileMode = FileMode.EXECUTABLE_FILE; } else { fileMode = FileMode.REGULAR_FILE; } createBlob(repositoryInserter, treeHierarchy, item.getServerItem(), blobID, fileMode, progressMonitor); } finally { if (tempInputStream != null) { tempInputStream.close(); } if (tempFile != null) { tempFile.delete(); } } }
Usage snippet has been bookmarked! Review your bookmarks
Thank you! Review your likes