1 package nl.hippo.cms.workflows.multiplesitessite; 2 3 import com.opensymphony.module.propertyset.PropertySet; 4 import java.io.IOException ; 5 import java.text.SimpleDateFormat ; 6 import java.util.Date ; 7 import java.util.HashMap ; 8 import java.util.Map ; 9 import nl.hippo.cms.Constants; 10 import nl.hippo.cms.repositorylocation.CommonRepositoryLocationRoles; 11 import nl.hippo.cms.repositorylocation.RepositoryInformation; 12 import nl.hippo.cms.repositorylocation.RepositoryLocation; 13 import nl.hippo.cms.sitesdirectory.SitesDirectory; 14 import nl.hippo.cms.workflows.shared.QueryDataRetriever2Component; 15 import nl.hippo.cocoon.webdav.WebDAVHelper; 16 import nl.hippo.servermanager.Project; 17 import org.apache.avalon.framework.service.ServiceException; 18 import org.apache.commons.httpclient.HttpState; 19 20 public class WaitingForPublicationReviewDataRetriever extends QueryDataRetriever2Component 21 { 22 23 public WaitingForPublicationReviewDataRetriever() 24 { 25 super(); 26 } 27 28 public Map getDataImpl(Project project, long workflowId, String uri, String repositoryRootUri, 29 HttpState httpState) throws IOException 30 { 31 Map result = new HashMap (); 32 33 try 34 { 35 RepositoryLocation editorRepoLocation = (RepositoryLocation) m_manager 36 .lookup(CommonRepositoryLocationRoles.EDITOR_REPOSITORY_LOCATION_ROLE); 37 try 38 { 39 RepositoryInformation editorRepoInfo = editorRepoLocation 40 .getRepositoryInformation(); 41 String absoluteUri = editorRepoInfo.getAbsoluteUri(uri); 42 String lastUserName = WebDAVHelper.propfindAsString(absoluteUri, 43 Constants.CMS_1_0_NAMESPACE, Constants.LAST_WORKFLOW_USER_PROPERTY_NAME, 44 httpState); 45 if (lastUserName != null && !lastUserName.equals("")) 46 { 47 String displayName = WebDAVHelper.propfindAsString(repositoryRootUri 48 + "/users/" + lastUserName, "DAV:", "displayname", httpState); 49 if (displayName != null && !displayName.equals("")) 50 { 51 lastUserName = displayName; 52 } 53 } 54 result.put("person", lastUserName); 55 56 PropertySet ps = project.getWorkflowRepository().getPropertySet(workflowId); 57 58 String publicationDateMode = ps.getString("requestedPublicationDateMode"); 59 if (publicationDateMode.equals("now")) 60 { 61 result.put("date", "-"); 62 } 63 else 64 { 65 Date publicationDate = ps.getDate("requestedPublicationDate"); 66 67 SimpleDateFormat displayFormat = new SimpleDateFormat ("dd-MM-yyyy"); 69 String requestedPublicationDateAsDisplayed = displayFormat 70 .format(publicationDate); 71 72 result.put("date", requestedPublicationDateAsDisplayed); 73 } 74 75 String siteId = ps.getString("siteId"); 76 SitesDirectory sitesDir = (SitesDirectory) m_manager.lookup(SitesDirectory.ROLE); 77 try 78 { 79 result.put("site", sitesDir.getSite(siteId).getName("en")); 81 } 82 finally 83 { 84 m_manager.release(sitesDir); 85 } 86 } 87 finally 88 { 89 m_manager.release(editorRepoLocation); 90 } 91 } 92 catch (ServiceException e) 93 { 94 } 96 catch (Exception e) 97 { 98 } 100 101 return result; 102 } 103 104 } 105 | Popular Tags |