Usages of

com.microsoft.tfs.core.clients.versioncontrol.soapextensions.Item.getItemID()
private String getLocalItemToView(final Change change, final TFSRepository repository) { Item item = change.getItem(); if (ViewVersionType.PREVIOUS == viewVersionType || ViewVersionType.LATEST == viewVersionType) { int version; if (ViewVersionType.PREVIOUS == viewVersionType) { version = item.getChangeSetID() - 1; } else { // Latest version = Integer.MAX_VALUE; } item = repository.getVersionControlClient().getItem(item.getItemID(), version, true); } final String localFileName = ServerPath.getFileName(item.getServerItem()); return item.downloadFileToTempLocation(repository.getVersionControlClient(), localFileName).getAbsolutePath(); }
public TeamProject(final Item item, final VersionControlClient client) { // code omitted ... /** * @return the ID number for this team project's item. */ public int getItemID() { return item.getItemID(); }
@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()); }
@Override public boolean isValid(final boolean forEdit, final WorkItem linkingWorkItem) { if (forEdit) { return true; } final String inputPath = versionedItemText.getText().trim(); if (inputPath.length() == 0) { errorMessage = Messages.getString("VersionedItemLinkProvider.EnterPathToVersionedItem"); //$NON-NLS-1$ return false; } if (!inputPath.startsWith("$/")) //$NON-NLS-1$ { errorMessage = Messages.getString("VersionedItemLinkProvider.VersionedItemPathInvalid"); //$NON-NLS-1$ return false; } VersionSpec versionSpec; int changesetId = -1; if (!latestVersionMode) { final String inputChangeset = changesetText.getText(); if (inputChangeset.trim().length() == 0) { errorMessage = Messages.getString("VersionedItemLinkProvider.MustSpecifyChangesetId"); //$NON-NLS-1$ return false; } try { changesetId = Integer.parseInt(inputChangeset); } catch (final NumberFormatException ex) { final String messageFormat = Messages.getString("VersionedItemLinkProvider.InvalidChangesetIdFormat"); //$NON-NLS-1$ errorMessage = MessageFormat.format(messageFormat, inputChangeset); return false; } if (changesetId <= 0) { final String messageFormat = Messages.getString("VersionedItemLinkProvider.MustBeGreaterThanZeroFormat"); //$NON-NLS-1$ errorMessage = MessageFormat.format(messageFormat, Integer.toString(changesetId)); return false; } versionSpec = new ChangesetVersionSpec(changesetId); } else { versionSpec = LatestVersionSpec.INSTANCE; } VersionControlClient client; try { client = (VersionControlClient) server.getConnection().getClient(VersionControlClient.class); } catch (final Exception e) { throw new RuntimeException(e); } Item item = null; try { item = client.getItem(inputPath, versionSpec); } catch (final Exception ex) { errorMessage = ex.getLocalizedMessage(); return false; } if (item == null) { if (latestVersionMode) { final String messageFormat = Messages.getString("VersionedItemLinkProvider.SpecifiedVersionNotFoundFormat"); //$NON-NLS-1$ errorMessage = MessageFormat.format(messageFormat, inputPath); } else { final String messageFormat = Messages.getString("VersionedItemLinkProvider.ItemDoesNotExistFormat"); //$NON-NLS-1$ errorMessage = MessageFormat.format(messageFormat, inputPath, Integer.toString(changesetId)); } return false; } String toolSpecificId; String artifactType; if (latestVersionMode) { toolSpecificId = String.valueOf(item.getItemID()); artifactType = VersionControlConstants.LATEST_ITEM_ARTIFACT_TYPE; } else { try { /* * Skip the leading $/ when creating the input path, then URL * escape it. This is to escape any special URL characters (eg, * '&'). Yes, we encode the item twice. This is what the server * expects and requires, and very bad things can happen if you * do not do this. */ final String escapedPath = URLEncoder.encode(inputPath.substring(2), URL_ENCODING); toolSpecificId = URLEncoder.encode(escapedPath + "&changesetVersion=" //$NON-NLS-1$ + changesetId + "&deletionId=" //$NON-NLS-1$ + item.getDeletionID(), URL_ENCODING); } catch (final UnsupportedEncodingException e) { throw new RuntimeException(e); } artifactType = VersionControlConstants.VERSIONED_ITEM_ARTIFACT_TYPE; } versionedItemArtifactId = new ArtifactID(ToolNames.VERSION_CONTROL, artifactType, toolSpecificId); return true; }
Usage snippet has been bookmarked! Review your bookmarks
Thank you! Review your likes