1 17 package org.alfresco.repo.importer; 18 19 import java.io.Serializable ; 20 import java.util.Date ; 21 22 import org.alfresco.service.cmr.repository.NodeRef; 23 import org.alfresco.service.cmr.security.AccessPermission; 24 import org.alfresco.service.cmr.view.ImporterProgress; 25 import org.alfresco.service.namespace.QName; 26 import org.apache.commons.logging.Log; 27 import org.apache.commons.logging.LogFactory; 28 29 30 35 public class ImportTimerProgress implements ImporterProgress 36 { 37 private Date start = null; 38 private long nodeCreateCount = 0; 39 private long propCount = 0; 40 private long contentCount = 0; 41 private long nodeLinkedCount = 0; 42 private long aspectAdded = 0; 43 private long permissionCount = 0; 44 45 private Log logger = LogFactory.getLog(ImportTimerProgress.class);; 46 47 50 public ImportTimerProgress() 51 { 52 } 53 54 59 public ImportTimerProgress(Log logger) 60 { 61 this.logger = logger; 62 } 63 64 68 public void started() 69 { 70 start = new Date (); 71 nodeCreateCount = 0; 72 propCount = 0; 73 contentCount = 0; 74 nodeLinkedCount = 0; 75 aspectAdded = 0; 76 permissionCount = 0; 77 78 if (logger.isDebugEnabled()) 79 logger.debug("Import started at " + start + " (" + start.getTime() + ")"); 80 } 81 82 86 public void completed() 87 { 88 if (logger.isDebugEnabled()) 89 { 90 Date end = new Date (); 91 logger.debug("Import completed at " + end + " (" + end.getTime() + ")"); 92 dumpStats(end); 93 } 94 } 95 96 100 public void error(Throwable e) 101 { 102 if (logger.isDebugEnabled()) 103 { 104 Date end = new Date (); 105 logger.debug("Import completed at " + end + " (" + end.getTime() + ")"); 106 logger.debug("Error occured at " + end + " (" + end.getTime() + ")"); 107 logger.debug("Exception: " + e.toString()); 108 dumpStats(end); 109 } 110 } 111 112 116 public void nodeCreated(NodeRef nodeRef, NodeRef parentRef, QName assocName, QName childName) 117 { 118 nodeCreateCount++; 119 } 120 121 125 public void nodeLinked(NodeRef nodeRef, NodeRef parentRef, QName assocName, QName childName) 126 { 127 nodeLinkedCount++; 128 } 129 130 134 public void contentCreated(NodeRef nodeRef, String sourceUrl) 135 { 136 contentCount++; 137 } 138 139 143 public void propertySet(NodeRef nodeRef, QName property, Serializable value) 144 { 145 propCount++; 146 } 147 148 152 public void permissionSet(NodeRef nodeRef, AccessPermission permission) 153 { 154 permissionCount++; 155 } 156 157 161 public void aspectAdded(NodeRef nodeRef, QName aspect) 162 { 163 aspectAdded++; 164 } 165 166 171 private void dumpStats(Date end) 172 { 173 if (logger.isDebugEnabled()) 174 { 175 logger.debug("Import duration: " + (end.getTime() - start.getTime()) + " ms (Note: excluding commit time)"); 176 logger.debug(" Nodes created: " + nodeCreateCount); 177 logger.debug(" Nodes linked: " + nodeLinkedCount); 178 logger.debug(" Aspects Added: " + aspectAdded); 179 logger.debug(" Properties set: " + propCount); 180 logger.debug(" Content set: " + contentCount); 181 logger.debug(" Permissions set: " + permissionCount); 182 } 183 } 184 185 } 186 | Popular Tags |