findAllProjects(ITeamRepository repository, IProgressMonitor monitor)
+ throws TeamRepositoryException {
+ IProcessItemService service = (IProcessItemService) repository.getClientLibrary(IProcessItemService.class);
+ return CollectionUtils.removeNulls(service.findAllProjectAreas(IProcessClientService.ALL_PROPERTIES, monitor));
+ }
+
+}
diff --git a/com.ibm.team.tap.tools.attachmentsMigrator/src/com/ibm/team/tap/tools/attachmentsMigrator/internal/Repository.java b/com.ibm.team.tap.tools.attachmentsMigrator/src/com/ibm/team/tap/tools/attachmentsMigrator/internal/Repository.java
new file mode 100644
index 0000000..851764b
--- /dev/null
+++ b/com.ibm.team.tap.tools.attachmentsMigrator/src/com/ibm/team/tap/tools/attachmentsMigrator/internal/Repository.java
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Licensed Materials - Property of IBM
+ * (c) Copyright IBM Corporation 2019. All Rights Reserved.
+ *
+ * Note to U.S. Government Users Restricted Rights: Use,
+ * duplication or disclosure restricted by GSA ADP Schedule
+ * Contract with IBM Corp.
+ *******************************************************************************/
+package com.ibm.team.tap.tools.attachmentsMigrator.internal;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+
+import com.ibm.team.repository.client.ITeamRepository;
+import com.ibm.team.repository.client.TeamPlatform;
+import com.ibm.team.repository.client.ITeamRepository.ILoginHandler;
+import com.ibm.team.repository.client.ITeamRepository.ILoginHandler.ILoginInfo;
+import com.ibm.team.repository.common.TeamRepositoryException;
+
+/**
+ * Repository related commands
+ */
+public class Repository {
+
+ public static ITeamRepository login(IProgressMonitor monitor, String serverUri, String user, String password)
+ throws TeamRepositoryException {
+ if (!TeamPlatform.isStarted()) {
+ TeamPlatform.startup();
+ }
+
+ ITeamRepository repository = TeamPlatform.getTeamRepositoryService().getTeamRepository(serverUri);
+ repository.registerLoginHandler(new LoginHandler(user, password));
+ monitor.subTask("Contacting " + repository.getRepositoryURI() + "..."); //$NON-NLS-1$ //$NON-NLS-2$
+ repository.login(monitor);
+ monitor.subTask("User " + user + " has logged in to " + repository.getRepositoryURI()); //$NON-NLS-1$ //$NON-NLS-2$
+ return repository;
+ }
+
+ /**
+ * Internal login handler to perform the login to the repository
+ *
+ */
+ private static class LoginHandler implements ILoginHandler, ILoginInfo {
+
+ private String fUserId;
+ private String fPassword;
+
+ private LoginHandler(String userId, String password) {
+ fUserId = userId;
+ fPassword = password;
+ }
+
+ public String getUserId() {
+ return fUserId;
+ }
+
+ public String getPassword() {
+ return fPassword;
+ }
+
+ public ILoginInfo challenge(ITeamRepository repository) {
+ return this;
+ }
+ }
+}
diff --git a/com.ibm.team.tap.tools.attachmentsMigrator/src/com/ibm/team/tap/tools/attachmentsMigrator/util/AttachmentUpdateCommand.java b/com.ibm.team.tap.tools.attachmentsMigrator/src/com/ibm/team/tap/tools/attachmentsMigrator/util/AttachmentUpdateCommand.java
new file mode 100644
index 0000000..522b09a
--- /dev/null
+++ b/com.ibm.team.tap.tools.attachmentsMigrator/src/com/ibm/team/tap/tools/attachmentsMigrator/util/AttachmentUpdateCommand.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Licensed Materials - Property of IBM
+ * (c) Copyright IBM Corporation 2019. All Rights Reserved.
+ *
+ * Note to U.S. Government Users Restricted Rights: Use,
+ * duplication or disclosure restricted by GSA ADP Schedule
+ * Contract with IBM Corp.
+ *******************************************************************************/
+package com.ibm.team.tap.tools.attachmentsMigrator.util;
+
+public class AttachmentUpdateCommand {
+ private boolean fUpdate;
+ private boolean fRemoveDeletedLinks;
+ private boolean fRemoveMultipleWILinks;
+ private String fAddWorkItemId;
+ private boolean fDelete;
+
+ public AttachmentUpdateCommand(boolean update, boolean removeDeletedLinks, boolean removeMultipleWILinks, String workItemId, boolean delete) {
+ fUpdate= update;
+ fRemoveDeletedLinks= removeDeletedLinks;
+ fRemoveMultipleWILinks= removeMultipleWILinks;
+ fAddWorkItemId = workItemId;
+ fDelete = delete;
+ }
+
+ public boolean isUpdate() {
+ return fUpdate;
+ }
+
+ public boolean isRemoveDeletedLinks() {
+ return fRemoveDeletedLinks;
+ }
+
+ public boolean isRemoveMultipleWILinks() {
+ return fRemoveMultipleWILinks;
+ }
+
+ public String getWorkItemId() {
+ return fAddWorkItemId;
+ }
+
+ public boolean isDelete() {
+ return fDelete;
+ }
+}
diff --git a/com.ibm.team.tap.tools.attachmentsMigrator/src/com/ibm/team/tap/tools/attachmentsMigrator/util/Constants.java b/com.ibm.team.tap.tools.attachmentsMigrator/src/com/ibm/team/tap/tools/attachmentsMigrator/util/Constants.java
new file mode 100644
index 0000000..6e6a00a
--- /dev/null
+++ b/com.ibm.team.tap.tools.attachmentsMigrator/src/com/ibm/team/tap/tools/attachmentsMigrator/util/Constants.java
@@ -0,0 +1,14 @@
+/*******************************************************************************
+ * Licensed Materials - Property of IBM
+ * © Copyright IBM Corporation 2019. All Rights Reserved.
+ *
+ * U.S. Government Users Restricted Rights:
+ * Use, duplication or disclosure restricted by GSA ADP Schedule
+ * Contract with IBM Corp.
+ ******************************************************************************/
+package com.ibm.team.tap.tools.attachmentsMigrator.util;
+
+public final class Constants {
+ // Commands
+ public static final String COMMAND_ANALYZE_AND_UPDATE_ATTACHMENTS= "analyzeAndUpdateAttachments"; //$NON-NLS-1$
+}
\ No newline at end of file
diff --git a/com.ibm.team.tap.tools.attachmentsMigrator/src/com/ibm/team/tap/tools/attachmentsMigrator/util/LogUtils.java b/com.ibm.team.tap.tools.attachmentsMigrator/src/com/ibm/team/tap/tools/attachmentsMigrator/util/LogUtils.java
new file mode 100644
index 0000000..0c03d0d
--- /dev/null
+++ b/com.ibm.team.tap.tools.attachmentsMigrator/src/com/ibm/team/tap/tools/attachmentsMigrator/util/LogUtils.java
@@ -0,0 +1,109 @@
+/*******************************************************************************
+ * Licensed Materials - Property of IBM
+ * © Copyright IBM Corporation 2019,2024. All Rights Reserved.
+ *
+ * U.S. Government Users Restricted Rights:
+ * Use, duplication or disclosure restricted by GSA ADP Schedule
+ * Contract with IBM Corp.
+ ******************************************************************************/
+package com.ibm.team.tap.tools.attachmentsMigrator.util;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.core.appender.RollingFileAppender;
+import org.apache.logging.log4j.core.config.Configurator;
+import org.apache.logging.log4j.core.config.builder.api.AppenderComponentBuilder;
+import org.apache.logging.log4j.core.config.builder.api.ConfigurationBuilder;
+import org.apache.logging.log4j.core.config.builder.api.ConfigurationBuilderFactory;
+import org.apache.logging.log4j.core.config.builder.api.LayoutComponentBuilder;
+import org.apache.logging.log4j.core.config.builder.impl.BuiltConfiguration;
+
+import com.ibm.team.tap.tools.attachmentsMigrator.AttachmentMigrationUtility;
+
+/**
+ *
+ * Apache Log4j logger utilities.
+ *
+ *
+ */
+public class LogUtils {
+
+ private static Logger fLogger= null;
+ private static RollingFileAppender fRollingFileAppender;
+ private static Logger fRootLogger;
+
+ // 50 MB
+ private static long MAX_FILE_SIZE= 50000000;
+ private static int MAX_BACKUP_INDEX= 10;
+
+ private static Logger getLogger() {
+
+ if (fLogger == null) {
+ fLogger= LogManager.getLogger(AttachmentMigrationUtility.class);
+ }
+
+ return fLogger;
+ }
+
+ public static void setLogFile(String file) {
+
+ ConfigurationBuilder builder = ConfigurationBuilderFactory.newConfigurationBuilder();
+ builder.setConfigurationName("Default");
+ LayoutComponentBuilder layout = builder.newLayout("PatternLayout")
+ .addAttribute("pattern", "%d{dd MMM yyyy HH:mm:ss,SSSZ} [%t] %5p %c: %m%n");
+ AppenderComponentBuilder appender = builder.newAppender("TRS Validator Utility log file appender", "File")
+ .addAttribute("fileName", file)
+ .add(layout);
+ builder.add(appender);
+ Configurator.reconfigure(builder.build());
+
+ }
+
+ public static void logDebug(String message) {
+ getLogger().debug(message);
+ }
+
+ public static void logDebug(String message, Throwable throwable) {
+ getLogger().debug(message, throwable);
+ }
+
+ public static void logTrace(String message) {
+ getLogger().trace(message);
+ }
+
+ public static void logTrace(String message, Throwable throwable) {
+ getLogger().trace(message, throwable);
+ }
+
+ public static void logInfo(String message) {
+ getLogger().info(message);
+ }
+
+ public static void logInfo(String message, Throwable throwable) {
+ getLogger().info(message, throwable);
+ }
+
+ public static void logWarning(String message) {
+ getLogger().warn(message);
+ }
+
+ public static void logWarning(String message, Throwable throwable) {
+ getLogger().warn(message, throwable);
+ }
+
+ public static void logError(String message) {
+ getLogger().error(message);
+ }
+
+ public static void logError(String message, Throwable throwable) {
+ getLogger().error(message, throwable);
+ }
+
+ public static void logFatal(String message) {
+ getLogger().fatal(message);
+ }
+
+ public static void logFatal(String message, Throwable throwable) {
+ getLogger().fatal(message, throwable);
+ }
+}
diff --git a/com.ibm.team.tap.tools.attachmentsMigrator/src/com/ibm/team/tap/tools/attachmentsMigrator/util/ProgressMonitor.java b/com.ibm.team.tap.tools.attachmentsMigrator/src/com/ibm/team/tap/tools/attachmentsMigrator/util/ProgressMonitor.java
new file mode 100644
index 0000000..61cd0ff
--- /dev/null
+++ b/com.ibm.team.tap.tools.attachmentsMigrator/src/com/ibm/team/tap/tools/attachmentsMigrator/util/ProgressMonitor.java
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Licensed Materials - Property of IBM
+ * (c) Copyright IBM Corporation 2019. All Rights Reserved.
+ *
+ * Note to U.S. Government Users Restricted Rights: Use,
+ * duplication or disclosure restricted by GSA ADP Schedule
+ * Contract with IBM Corp.
+ *******************************************************************************/
+package com.ibm.team.tap.tools.attachmentsMigrator.util;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+
+public class ProgressMonitor implements IProgressMonitor {
+
+ public void beginTask(String name, int totalWork) {
+ print(name);
+ }
+
+ public void done() {
+ }
+
+ public void internalWorked(double work) {
+ }
+
+ public boolean isCanceled() {
+ return false;
+ }
+
+ public void setCanceled(boolean value) {
+ }
+
+ public void setTaskName(String name) {
+ print(name);
+ }
+
+ public void subTask(String name) {
+ print(name);
+ }
+
+ public void worked(int work) {
+ }
+
+ private void print(String name) {
+ if (name != null && !"".equals(name)) //$NON-NLS-1$
+ System.out.println(name);
+ }
+}
diff --git a/com.ibm.team.tap.tools.attachmentsMigrator/src/com/ibm/team/tap/tools/attachmentsMigrator/util/WIAttachmentInfo.java b/com.ibm.team.tap.tools.attachmentsMigrator/src/com/ibm/team/tap/tools/attachmentsMigrator/util/WIAttachmentInfo.java
new file mode 100644
index 0000000..20fdd25
--- /dev/null
+++ b/com.ibm.team.tap.tools.attachmentsMigrator/src/com/ibm/team/tap/tools/attachmentsMigrator/util/WIAttachmentInfo.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Licensed Materials - Property of IBM
+ * (c) Copyright IBM Corporation 2019. All Rights Reserved.
+ *
+ * Note to U.S. Government Users Restricted Rights: Use,
+ * duplication or disclosure restricted by GSA ADP Schedule
+ * Contract with IBM Corp.
+ *******************************************************************************/
+package com.ibm.team.tap.tools.attachmentsMigrator.util;
+
+public class WIAttachmentInfo {
+ private String fProjectName;
+ private int fWorkItemId;
+ private String fAttachmentName;
+ private int fAttachmentId;
+ private long fContentLength;
+
+ public WIAttachmentInfo(String projectName, int workItemId, String attachmentName, int attachmentId, long contentLength) {
+ fProjectName= projectName;
+ fWorkItemId= workItemId;
+ fAttachmentName= attachmentName;
+ fAttachmentId= attachmentId;
+ fContentLength= contentLength;
+ }
+
+ public String getAttachmentName() {
+ return fAttachmentName;
+ }
+
+ public int getAttachmentId() {
+ return fAttachmentId;
+ }
+
+ public int getWorkItemId() {
+ return fWorkItemId;
+ }
+
+ public String getProjectName() {
+ return fProjectName;
+ }
+
+ public long getContentLength() {
+ return fContentLength;
+ }
+}