1 11 package org.eclipse.team.internal.ccvs.core.client; 12 13 14 import org.eclipse.core.resources.IResource; 15 import org.eclipse.core.runtime.*; 16 import org.eclipse.osgi.util.NLS; 17 import org.eclipse.team.internal.ccvs.core.*; 18 19 32 33 37 class RemovedHandler extends ResponseHandler { 38 public String getResponseID() { 39 return "Removed"; } 41 42 public void handle(Session session, String localDir, IProgressMonitor monitor) throws CVSException { 43 44 String repositoryFile = session.readLine(); 46 47 String fileName = repositoryFile.substring(repositoryFile.lastIndexOf("/") + 1); ICVSFolder mParent = session.getLocalRoot().getFolder(localDir); 50 ICVSFile mFile = mParent.getFile(fileName); 51 52 if ( ! mFile.isManaged()) { 53 IStatus status = new CVSStatus(IStatus.ERROR,CVSStatus.ERROR,NLS.bind(CVSMessages.RemovedHandler_invalid, new String [] { new Path(null, localDir).append(fileName).toString() }),session.getLocalRoot()); 54 throw new CVSException(status); 55 } 56 57 try { 59 if (mFile.isReadOnly()) mFile.setReadOnly(false); 60 mFile.delete(); 61 mFile.unmanage(null); 62 } catch (CVSException e) { 63 IStatus status = new CVSStatus(IStatus.ERROR, CVSStatus.RESPONSE_HANDLING_FAILURE, NLS.bind(CVSMessages.RemovedHandler_0, new String [] { getPath(mFile) }), e, session.getLocalRoot()); 64 session.handleResponseError(status); 65 } 66 } 67 68 private String getPath(ICVSFile file) { 69 IResource resource = file.getIResource(); 70 if (resource != null) { 71 return resource.getFullPath().toString(); 72 } 73 try { 74 return file.getRepositoryRelativePath(); 75 } catch (CVSException e1) { 76 return file.getName(); 77 } 78 } 79 } 80 81 | Popular Tags |