1 11 package org.eclipse.team.internal.ccvs.core; 12 13 import org.eclipse.core.resources.IResource; 14 import org.eclipse.core.runtime.IStatus; 15 import org.eclipse.osgi.util.NLS; 16 import org.eclipse.team.core.TeamStatus; 17 import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; 18 import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo; 19 import org.eclipse.team.internal.ccvs.core.util.KnownRepositories; 20 21 public class CVSStatus extends TeamStatus { 22 23 24 public static final int SERVER_ERROR = -10; 25 public static final int NO_SUCH_TAG = -11; 26 public static final int CONFLICT = -12; 27 public static final int ERROR_LINE = -14; public static final int TAG_ALREADY_EXISTS = -15; 29 public static final int COMMITTING_SYNC_INFO_FAILED = -16; 30 public static final int DOES_NOT_EXIST = -17; 31 public static final int FOLDER_NEEDED_FOR_FILE_DELETIONS = -18; 32 public static final int CASE_VARIANT_EXISTS = -19; 33 public static final int UNSUPPORTED_SERVER_VERSION = -20; 34 public static final int SERVER_IS_CVSNT = -21; 35 public static final int SERVER_IS_UNKNOWN = -22; 36 public static final int PROTOCOL_ERROR = -23; 37 public static final int ERROR_LINE_PARSE_FAILURE = -24; 38 public static final int FAILED_TO_CACHE_SYNC_INFO = -25; 39 public static final int UNMEGERED_BINARY_CONFLICT = -26; 40 public static final int INVALID_LOCAL_RESOURCE_PATH = -27; 41 public static final int RESPONSE_HANDLING_FAILURE = -28; 42 public static final int COMMUNICATION_FAILURE = -29; 43 public static final int AUTHENTICATION_FAILURE = -30; 44 45 private ICVSFolder commandRoot; 47 private ICVSRepositoryLocation cvsLocation; 49 50 public CVSStatus(int severity, int code, String message, Throwable t, ICVSRepositoryLocation cvsLocation) { 51 super(severity, CVSProviderPlugin.ID, code, message, t,null); 52 this.cvsLocation = cvsLocation; 53 } 54 55 public CVSStatus(int severity, int code, String message,ICVSRepositoryLocation cvsLocation) { 56 this(severity, code, message, null, cvsLocation); 57 } 58 59 public CVSStatus(int severity, int code, String message, Throwable t, IResource cvsResource) { 60 super(severity, CVSProviderPlugin.ID, code, message, t, cvsResource); 61 } 62 63 public CVSStatus(int severity, int code, String message, IResource resource) { 64 this(severity, code, message, null, resource); 65 } 66 67 public CVSStatus(int severity, int code, String message, Throwable t, ICVSFolder commandRoot) { 68 super(severity, CVSProviderPlugin.ID, code, message, t, null); 69 this.commandRoot = commandRoot; 70 } 71 72 public CVSStatus(int severity, int code, String message, ICVSFolder commandRoot) { 73 this(severity, code, message, null, commandRoot); 74 } 75 76 public CVSStatus(int severity, int code, String message, Throwable t) { 77 super(severity, CVSProviderPlugin.ID, code, message, t, null); 78 } 79 80 public CVSStatus(int severity, String message, Throwable t) { 81 super(severity, CVSProviderPlugin.ID, CVSStatus.ERROR, message, t, null); 82 } 83 84 public CVSStatus(int severity, String message) { 85 super(severity, CVSProviderPlugin.ID, CVSStatus.ERROR, message, null, null); 86 } 87 88 91 public String getMessage() { 92 String message = super.getMessage(); 93 if (commandRoot != null) { 94 message = NLS.bind(CVSMessages.CVSStatus_messageWithRoot, new String [] { commandRoot.getName(), message }); 95 } 96 return message; 97 } 98 99 106 public boolean isInternalError() { 107 Throwable ex = getException(); 108 if (ex instanceof CVSException) { 109 CVSException cvsEx = (CVSException) ex; 110 IStatus status = cvsEx.getStatus(); 111 return isInternalError(status); 112 } 113 return ex != null; 114 } 115 116 123 public static boolean isInternalError(IStatus status) { 124 if (status instanceof CVSStatus) { 125 return ((CVSStatus)status).isInternalError(); 126 } 127 if (status.isMultiStatus()) { 128 IStatus[] children = status.getChildren(); 129 for (int i = 0; i < children.length; i++) { 130 IStatus child = children[i]; 131 if (isInternalError(child)) { 132 return true; 133 } 134 } 135 return false; 136 } 137 return true; 138 } 139 140 public ICVSRepositoryLocation getCvsLocation() { 141 if (cvsLocation==null){ 142 try { 143 if (commandRoot!=null){ 144 FolderSyncInfo info = commandRoot.getFolderSyncInfo(); 145 if (info!=null){ 146 String repoString = info.getRoot(); 147 cvsLocation = KnownRepositories.getInstance().getRepository(repoString); 148 } 149 } else if (getResource()!=null){ 150 ICVSFolder folder = CVSWorkspaceRoot.getCVSFolderFor(getResource().getProject()); 151 FolderSyncInfo info = folder.getFolderSyncInfo(); 152 if (info!=null){ 153 String repoString = info.getRoot(); 154 cvsLocation = KnownRepositories.getInstance().getRepository(repoString); 155 } 156 } 157 } catch (CVSException e){ 158 } 161 } 162 return cvsLocation; 163 } 164 165 public ICVSFolder getCommandRoot() { 166 return commandRoot; 167 } 168 169 170 } 171 | Popular Tags |