1 31 32 package org.opencms.file.collectors; 33 34 import org.opencms.file.types.I_CmsResourceType; 35 import org.opencms.loader.CmsLoaderException; 36 import org.opencms.main.CmsIllegalArgumentException; 37 import org.opencms.main.CmsLog; 38 import org.opencms.main.CmsRuntimeException; 39 import org.opencms.main.OpenCms; 40 41 import org.apache.commons.logging.Log; 42 43 54 public class CmsCollectorData { 55 56 57 private static final Log LOG = CmsLog.getLog(CmsCollectorData.class); 58 59 60 private int m_count; 61 62 63 private String m_fileName; 64 65 66 private int m_type; 67 68 74 public CmsCollectorData(String data) { 75 76 if (data == null) { 77 throw new CmsIllegalArgumentException(Messages.get().container(Messages.ERR_COLLECTOR_PARAM_EMPTY_0)); 78 } 79 80 int pos1 = data.indexOf('|'); 81 if (pos1 == -1) { 82 throw new CmsIllegalArgumentException( 83 Messages.get().container(Messages.ERR_COLLECTOR_PARAM_INVALID_1, data)); 84 } 85 86 int pos2 = data.indexOf('|', pos1 + 1); 87 if (pos2 == -1) { 88 pos2 = data.length(); 89 m_count = 0; 90 } else { 91 m_count = Integer.valueOf(data.substring(pos2 + 1)).intValue(); 92 } 93 94 m_fileName = data.substring(0, pos1); 95 String type = data.substring(pos1 + 1, pos2); 96 try { 97 I_CmsResourceType resourceType = OpenCms.getResourceManager().getResourceType(type); 99 m_type = resourceType.getTypeId(); 100 } catch (CmsLoaderException e) { 101 int typeInt = Integer.valueOf(type).intValue(); 103 try { 104 I_CmsResourceType resourceType = OpenCms.getResourceManager().getResourceType(typeInt); 105 m_type = resourceType.getTypeId(); 106 if (LOG.isWarnEnabled()) { 107 LOG.warn(Messages.get().getBundle().key( 108 Messages.LOG_RESTYPE_INTID_2, 109 resourceType.getTypeName(), 110 new Integer (m_type))); 111 } 112 } catch (CmsLoaderException e1) { 113 throw new CmsRuntimeException(Messages.get().container(Messages.ERR_UNKNOWN_RESTYPE_1, type), e1); 115 } 116 } 117 } 118 119 125 public int getCount() { 126 127 return m_count; 128 } 129 130 136 public String getFileName() { 137 138 return m_fileName; 139 } 140 141 147 public int getType() { 148 149 return m_type; 150 } 151 } 152 | Popular Tags |