Usages of

com.microsoft.tfs.core.clients.versioncontrol.soapextensions.Item.getEncoding()
public DiffItem( final Item item, final String localPath, final String tempFile, final DiffItem rootItem, final VersionSpec version) { this( item.getServerItem(), localPath, tempFile, item.getEncoding().getCodePage(), rootItem, item.getItemType(), item.getCheckinDate().getTimeInMillis(), true, version); Check.notNull(item, "item"); //$NON-NLS-1$ this.item = item; changesetVersion = item.getChangeSetID(); }
@Override public void updateFrom(final Item item) { Check.isTrue(0 != versionLocal, "Attempted to update a ClientLocalVersionUpdate for an uncommitted item"); //$NON-NLS-1$ encoding = item.getEncoding().getCodePage(); if (VersionControlConstants.ENCODING_FOLDER != encoding) { baselineFileLength = item.getContentLength(); baselineHashValue = item.getContentHashValue(); versionLocalDate = DotNETDate.MIN_CALENDAR.equals(item.getCheckinDate()) ? -1 : DotNETDate.toWindowsFileTimeUTC(item.getCheckinDate()); } }
public TFSItemNode(final Item item, final VersionControlClient vcClient) { // code omitted ... @Override public String getCharset() throws CoreException { final int codePage = item.getEncoding().getCodePage(); return CodePageMapping.getEncoding(codePage, false, false); }
private LineComparator getComparator(final Changeset cs, final String tmpFile) throws FileNotFoundException, IOException { final Item item = cs.getChanges()[0].getItem(); return new LineComparator(new FileInputStream(tmpFile), item.getEncoding().getName()); }
@Override public int getEncoding() throws CLCException { if (encoding == 0) { if (pendingChange.getChangeType().contains(ChangeType.ENCODING) && pendingChange.getVersion() != 0) { final Item item = client.getItem(pendingChange.getItemID(), pendingChange.getVersion(), false); Check.notNull(item, "item"); //$NON-NLS-1$ encoding = item.getEncoding().getCodePage(); } else { encoding = pendingChange.getEncoding(); } } return encoding; }
/* * (non-Javadoc) * * @see org.eclipse.compare.IEncodedStreamContentAccessor#getCharset() */ @Override public String getCharset() throws CoreException { /* * We try to detect the charset if none was given. (We do this here as * we're being run off the UI thread, before getCharset() is called.) */ if (charset == null && file.exists() && file.isDirectory() == false) { final TFSRepository repository = TFSCommonUIClientPlugin.getDefault().getProductPlugin().getRepositoryManager().getDefaultRepository(); /* * If we're online, query the pending changes cache for a pending * type change. */ if (repository != null) { final PendingChange pendingChange = repository.getPendingChangeCache().getPendingChangeByLocalPath(file.getAbsolutePath()); /* Use the pending encoding change if it exists. */ if (pendingChange != null && pendingChange.getChangeType().contains(ChangeType.ENCODING)) { charset = CodePageMapping.getCharset(pendingChange.getEncoding(), false); } /* * Adds and branches should always have encoding changes (this * test should always be true). */ else if (pendingChange == null || (!pendingChange.getChangeType().contains(ChangeType.ADD) && !pendingChange.getChangeType().contains(ChangeType.BRANCH))) { /* * Make sure this file is in a mapping. (Avoid querying the * server unnecessarily.) */ final String serverPath = repository.getWorkspace().getMappedServerPath(file.getAbsolutePath()); if (serverPath != null) { /* * See if we can query this item at the workspace * version. */ final Item item = repository.getWorkspace().getClient().getItem( serverPath, new WorkspaceVersionSpec(repository.getWorkspace())); if (item != null) { charset = CodePageMapping.getCharset(item.getEncoding().getCodePage(), false); } } } } } if (charset != null) { return charset.name(); } return ResourcesPlugin.getEncoding(); }
/** * Download the TFSBuild.proj file specified in the passed {@link Item}, * then attempt to parse it for the values required for the returned * {@link BuildTypeInfo}. * * @param server * the build server (must not be <code>null</code>) * @param item * An {@link Item} representing the TFSBuild.proj file for the build * type. * @return parsed values for the passed AItem. * @throws IOException * if Exception occurred reading or parsing item. */ public static BuildTypeInfo parseBuildTypeFile(final IBuildServer server, final Item item) throws IOException { // Download file to temp location Check.notNull(item, "item"); //$NON-NLS-1$ final String buildTypeName = ServerPath.getFileName(ServerPath.getParent(item.getServerItem())); final String fileName = MessageFormat.format("{0}-{1}", buildTypeName, BuildConstants.PROJECT_FILE_NAME); //$NON-NLS-1$ final File localBuildFile = item.downloadFileToTempLocation(server.getConnection().getVersionControlClient(), fileName); BuildTypeInfo info; try { info = parseBuildTypeInfo(buildTypeName, localBuildFile, item.getEncoding()); } finally { try { localBuildFile.delete(); } catch (final Exception e) { // We did our best, log and ignore. log.error(Messages.getString("BuildTypeUtil.ErrorDeletingTemporaryBuildProjectFile"), e); //$NON-NLS-1$ } TempStorageService.getInstance().cleanUpItem(localBuildFile.getParentFile()); } return info; }
public void setItem(final Item item) { if (item != null) { itemType = item.getItemType(); itemTypeServerString = item.getItemType().toUIString(); serverItemServer = item.getServerItem(); versionServer = item.getChangeSetID(); deletionID = item.getDeletionID(); /* * TODO Get the server's time zone and convert from it to local * time. */ checkinDateString = FORMATTER.format(item.getCheckinDate().getTime()); if (item.getItemType() == ItemType.FILE && item.getEncoding().equals( new FileEncoding(VersionControlConstants.ENCODING_UNCHANGED)) == false) { encodingString = item.getEncoding().getName(); } fileLength = item.getContentLength(); } }
@Override protected void populate(final PropertyHolder propertyHolder) { final Item item = change.getItem(); propertyHolder.addProperty( Messages.getString("ChangePropertySource.ChangeTypesPropertyName"), //$NON-NLS-1$ Messages.getString("ChangePropertySource.ChangeTypesPropertyDescription"), //$NON-NLS-1$ change.getChangeType().toUIString(true, item)); propertyHolder.addProperty( Messages.getString("ChangePropertySource.ChangesetIdPropertyName"), //$NON-NLS-1$ String.valueOf(item.getChangeSetID())); final Calendar c = item.getCheckinDate(); Object value = (c != null ? dateFormat.format(c.getTime()) : null); propertyHolder.addProperty( Messages.getString("ChangePropertySource.CheckinDatePropertyName"), //$NON-NLS-1$ Messages.getString("ChangePropertySource.CheckinDatePropertyDescription"), //$NON-NLS-1$ value); propertyHolder.addProperty( Messages.getString("ChangePropertySource.DeletionIdPropertyName"), //$NON-NLS-1$ String.valueOf(item.getDeletionID())); propertyHolder.addProperty( Messages.getString("ChangePropertySource.EncodingPropertyName"), //$NON-NLS-1$ String.valueOf(item.getEncoding())); final ItemType itemType = item.getItemType(); value = (itemType != null ? itemType.toString() : null); propertyHolder.addProperty( Messages.getString("ChangePropertySource.ItemTypePropertyName"), //$NON-NLS-1$ Messages.getString("ChangePropertySource.ItemTypePropertyDescription"), //$NON-NLS-1$ value); propertyHolder.addProperty( Messages.getString("ChangePropertySource.ItemIdPropertyName"), //$NON-NLS-1$ String.valueOf(item.getItemID())); propertyHolder.addProperty( Messages.getString("ChangePropertySource.ServerItemPropertyName"), //$NON-NLS-1$ Messages.getString("ChangePropertySource.ServerItemPropertyDescription"), //$NON-NLS-1$ item.getServerItem()); propertyHolder.addProperty(Messages.getString("ChangePropertySource.TimeZonePropertyName"), item.getTimeZone()); //$NON-NLS-1$ propertyHolder.addProperty( Messages.getString("ChangePropertySource.TimeZoneOffsetPropertyName"), //$NON-NLS-1$ item.getTimeZoneO()); final byte[] hash = item.getContentHashValue(); value = (hash != null ? ArrayUtils.byteArrayToHexString(hash) : null); propertyHolder.addProperty(Messages.getString("ChangePropertySource.HashValuePropertyName"), value); //$NON-NLS-1$ propertyHolder.addProperty( Messages.getString("ChangePropertySource.ContentLengthPropertyName"), //$NON-NLS-1$ String.valueOf(item.getContentLength())); propertyHolder.addProperty( Messages.getString("ChangePropertySource.DownloadUrlPropertyName"), //$NON-NLS-1$ item.getDownloadURL()); }
public void applyFileAttributesToTempFile( final String targetServerItem, final String targetLocalItem, final int encoding, final File tempFile, final GetOperation operation) { if (targetServerItem == null || targetLocalItem == null) { return; } Check.notNull(tempFile, "tempFile"); //$NON-NLS-1$ final FileAttributesCollection attributes = getAttributesForFile(targetLocalItem, targetServerItem, isTextEncoding(encoding)); if (attributes != null) { /* * Handle AppleSingle decoding: this must be done first, as other * operations need to deal with the data fork that will be decoded * from this file. */ final StringPairFileAttribute transformAttribute = attributes.getStringPairFileAttribute(FileAttributeNames.TRANSFORM); if (transformAttribute != null && "apple".equals(transformAttribute.getValue()) //$NON-NLS-1$ && AppleSingleUtil.isSupportedPlatform()) { log.debug(MessageFormat.format("Decoding AppleSingle file for {0}", targetLocalItem)); //$NON-NLS-1$ try { AppleSingleUtil.decodeFile(tempFile); } catch (final IOException e) { final String message = MessageFormat.format( Messages.getString("GetEngine.CouldNotDecodeAppleSingleFileFormat"), //$NON-NLS-1$ targetLocalItem, e.getLocalizedMessage()); log.warn(message, e); onNonFatalError(new TECoreException(message)); } } /* Handle EOL conversion */ final StringPairFileAttribute eolAttribute = attributes.getStringPairFileAttribute(FileAttributeNames.CLIENT_EOL); if (eolAttribute != null && eolAttribute.getValue() != null) { if (encoding == VersionControlConstants.ENCODING_UNCHANGED && client.getServiceLevel().getValue() < WebServiceLevel.TFS_2012.getValue() && operation != null) { final Item item = client.getItem(operation.getItemID(), operation.getVersionServer()); operation.setEncoding(item.getEncoding().getCodePage()); } if (operation.getEncoding() != FileEncoding.BINARY.getCodePage()) { final String desiredNewlineSequence = FileAttributeValues.getEndOfLineStringForAttributeValue(eolAttribute); if (desiredNewlineSequence == null) { onNonFatalError( new TECoreException( MessageFormat.format( Messages.getString("GetEngine.UnsupportedClientEOLStyleFormat"), //$NON-NLS-1$ eolAttribute.getValue(), targetLocalItem, FileAttributesFile.DEFAULT_FILENAME))); } else if (desiredNewlineSequence.equals("")) //$NON-NLS-1$ { log.debug(MessageFormat.format("Not converting line endings for {0}", targetLocalItem)); //$NON-NLS-1$ } else { log.debug(MessageFormat.format( "Converting line endings for {0} to {1}", //$NON-NLS-1$ targetLocalItem, eolAttribute.getValue())); try { Charset charset = CodePageMapping.getCharset(operation.getEncoding(), false); if (charset == null) { charset = Charset.defaultCharset(); } NewlineUtils.convertFile(tempFile, charset, desiredNewlineSequence); log.info(MessageFormat.format( "Converted line endings in {0} to {1} (using charset {2})", //$NON-NLS-1$ tempFile, eolAttribute.getValue(), charset.name())); } catch (final UnsupportedEncodingException e) { final String message = MessageFormat.format( Messages.getString("GetEngine.CouldNotChangeEOLBecauseUnknownFileEncodingFormat"), //$NON-NLS-1$ targetLocalItem, e.getLocalizedMessage()); log.error(message, e); onNonFatalError(new TECoreException(message)); } catch (final IOException e) { final String message = MessageFormat.format( Messages.getString("GetEngine.CouldNotChangeEOLBecauseIOExceptionFormat"), //$NON-NLS-1$ targetLocalItem, e.getLocalizedMessage()); log.error(message, e); onNonFatalError(new TECoreException(message)); } } } } } }
Usage snippet has been bookmarked! Review your bookmarks
Thank you! Review your likes