1 31 32 package org.opencms.configuration; 33 34 import org.opencms.file.CmsResource; 35 import org.opencms.file.types.A_CmsResourceType; 36 import org.opencms.util.CmsMacroResolver; 37 38 50 public class CmsConfigurationCopyResource { 51 52 53 public static final String COPY_AS_NEW = "new"; 54 55 56 public static final String COPY_AS_PRESERVE = "preserve"; 57 58 59 public static final String COPY_AS_SIBLING = "sibling"; 60 61 62 private String m_source; 63 64 65 private String m_target; 66 67 68 private boolean m_targetWasNull; 69 70 71 private int m_type; 72 73 74 private boolean m_typeWasNull; 75 76 86 public CmsConfigurationCopyResource(String source, String target, String type) { 87 88 m_source = source; 89 90 if (target == null) { 91 m_target = CmsMacroResolver.formatMacro(A_CmsResourceType.MACRO_RESOURCE_FOLDER_PATH); 92 m_targetWasNull = true; 93 } else { 94 m_target = target; 95 } 96 97 m_type = CmsResource.COPY_AS_NEW; 98 if (type != null) { 99 if (type.equalsIgnoreCase(CmsConfigurationCopyResource.COPY_AS_SIBLING)) { 100 m_type = CmsResource.COPY_AS_SIBLING; 101 } else if (type.equalsIgnoreCase(CmsConfigurationCopyResource.COPY_AS_PRESERVE)) { 102 m_type = CmsResource.COPY_PRESERVE_SIBLING; 103 } 104 } else { 105 m_typeWasNull = true; 106 } 107 } 108 109 114 public String getSource() { 115 116 return m_source; 117 } 118 119 124 public String getTarget() { 125 126 return m_target; 127 } 128 129 137 public int getType() { 138 139 return m_type; 140 } 141 142 149 public String getTypeString() { 150 151 if (CmsResource.COPY_AS_SIBLING == m_type) { 152 return CmsConfigurationCopyResource.COPY_AS_SIBLING; 153 } else if (CmsResource.COPY_PRESERVE_SIBLING == m_type) { 154 return CmsConfigurationCopyResource.COPY_AS_PRESERVE; 155 } 156 return CmsConfigurationCopyResource.COPY_AS_NEW; 157 } 158 159 164 public boolean isTargetWasNull() { 165 166 return m_targetWasNull; 167 } 168 169 174 public boolean isTypeWasNull() { 175 176 return m_typeWasNull; 177 } 178 179 182 public String toString() { 183 184 StringBuffer result = new StringBuffer (); 185 186 result.append("["); 187 result.append(this.getClass().getName()); 188 result.append(", source="); 189 result.append(getSource()); 190 result.append(", target="); 191 result.append(getTarget()); 192 result.append(", type="); 193 result.append(getTypeString()); 194 result.append("]"); 195 196 return result.toString(); 197 } 198 } | Popular Tags |