1 16 package org.apache.cocoon.components.repository.impl; 17 18 import java.io.IOException ; 19 import java.util.List ; 20 21 import org.apache.avalon.framework.activity.Disposable; 22 import org.apache.avalon.framework.component.Component; 23 import org.apache.avalon.framework.logger.AbstractLogEnabled; 24 import org.apache.avalon.framework.service.ServiceException; 25 import org.apache.avalon.framework.service.ServiceManager; 26 import org.apache.avalon.framework.service.Serviceable; 27 import org.apache.cocoon.components.repository.helpers.CredentialsToken; 28 import org.apache.cocoon.components.repository.helpers.RepositoryVersioningHelper; 29 import org.apache.cocoon.components.webdav.WebDAVUtil; 30 import org.apache.commons.httpclient.HttpException; 31 32 36 public class WebDAVRepositoryVersioningHelper extends AbstractLogEnabled 37 implements RepositoryVersioningHelper, Serviceable, Disposable, Component { 38 39 40 private ServiceManager manager; 41 42 43 private WebDAVRepository repo; 44 45 46 private CredentialsToken credentials; 47 48 51 public void service(ServiceManager manager) throws ServiceException { 52 this.manager = manager; 53 } 54 55 58 public void dispose() { 59 this.manager = null; 60 } 61 62 68 public WebDAVRepositoryVersioningHelper (CredentialsToken credentials, WebDAVRepository repo) { 69 this.credentials = credentials; 70 this.repo = repo; 71 } 72 73 76 public boolean checkout(String uri) { 77 78 try { 79 WebDAVUtil.getWebdavResource(this.repo.getAbsoluteURI(uri)).checkoutMethod(); 80 return true; 81 82 } catch (HttpException he) { 83 this.getLogger().error("HTTP Error checking out " + uri, he); 84 } catch (IOException ioe) { 85 this.getLogger().error("IO Error checking out " + uri, ioe); 86 } 87 88 return false; 89 } 90 91 94 public boolean checkin(String uri) { 95 96 try { 97 WebDAVUtil.getWebdavResource(this.repo.getAbsoluteURI(uri)).checkinMethod(); 98 return true; 99 100 } catch (HttpException he) { 101 this.getLogger().error("HTTP Error checking in " + uri, he); 102 } catch (IOException ioe) { 103 this.getLogger().error("IO Error checking in " + uri, ioe); 104 } 105 106 return false; 107 } 108 109 112 public boolean uncheckout(String uri) { 113 114 try { 115 WebDAVUtil.getWebdavResource(this.repo.getAbsoluteURI(uri)).uncheckoutMethod(); 116 return true; 117 118 } catch (HttpException he) { 119 this.getLogger().error("HTTP Error while uncheckout " + uri, he); 120 } catch (IOException ioe) { 121 this.getLogger().error("IO Error while uncheckout " + uri, ioe); 122 } 123 124 return false; 125 } 126 127 130 public boolean isVersioned(String uri) { 131 throw new UnsupportedOperationException (); 133 } 134 135 138 public boolean setVersioned(final String uri, final boolean versioned) { 139 140 try { 141 if(!versioned) { 142 return false; 143 144 } else { 145 return WebDAVUtil.getWebdavResource(this.repo.getAbsoluteURI(uri)) 146 .versionControlMethod(this.repo.getAbsoluteURI(uri)); 147 } 148 149 } catch (HttpException he) { 150 this.getLogger().error("HTTP Error while versioncontrol " + uri, he); 151 } catch (IOException ioe) { 152 this.getLogger().error("IO Error while versioncontrol " + uri, ioe); 153 } 154 155 return false; 156 } 157 158 161 public List getVersions(String uri) { 162 throw new UnsupportedOperationException (); 164 } 165 166 } | Popular Tags |