Map map = new HashMap();
SCHEMA:
for (Iterator i = dto.getFeaturesTypes().values().iterator();
i.hasNext();) {
FeatureTypeInfoDTO featureTypeDTO = (FeatureTypeInfoDTO) i.next();
if (featureTypeDTO == null) {
LOGGER.warning("Ignore null FeatureTypeInfo DTO!");
continue;
}
String key = featureTypeDTO.getKey(); // dataStoreId:typeName
LOGGER.finer("FeatureType " + key
+ ": loading feature type info dto:" + featureTypeDTO);
String dataStoreId = featureTypeDTO.getDataStoreId();
LOGGER.finest("FeatureType " + key + " looking up :" + dataStoreId);
DataStoreInfo dataStoreInfo = (DataStoreInfo) dataStores.get(dataStoreId);
if (dataStoreInfo == null) {
LOGGER.severe("FeatureTypeInfo " + key
+ " could not be used - DataStore " + dataStoreId
+ " is not defined!");
DataStoreInfoDTO tmp = (DataStoreInfoDTO) dto.getDataStores()
.get(dataStoreId);
if ((tmp != null) && (!tmp.isEnabled())) {
errors.put(featureTypeDTO, Boolean.FALSE);
} else {
errors.put(featureTypeDTO,
new ConfigurationException("FeatureTypeInfo " + key
+ " could not be used - DataStore " + dataStoreId
+ " is not defined!"));
}
continue;
} else {
LOGGER.finest(key + " datastore found :" + dataStoreInfo);
}
Style s = getStyle(featureTypeDTO.getDefaultStyle());
if (s == null) {
LOGGER.severe("FeatureTypeInfo " + key + " ignored - Style '"
+ featureTypeDTO.getDefaultStyle() + "' not found!");
errors.put(featureTypeDTO,
new ConfigurationException("FeatureTypeInfo " + key
+ " ignored - Style '"
+ featureTypeDTO.getDefaultStyle() + "' not found!"));
continue SCHEMA;
}
// Check attributes configured correctly against schema
String typeName = featureTypeDTO.getName();
try {
DataStore dataStore = dataStoreInfo.getDataStore();
FeatureType featureType = dataStore.getSchema(typeName);
Set attributeNames = new HashSet();
Set ATTRIBUTENames = new HashSet();
//as far as I can tell an emtpy list indicates that no
//schema.xml file was found. I may be approaching this
//all wrong, is this logic contained elsewhere?
//CH: Yeah, this shit was super messed up. It was causing null pointer
//exceptions, and then it created this createAttrDTO flag that wasn't
//then used by anyone. So I fixed the null and made it so it creates
//AttributeTypeInfoDTO's (once again, I hate these) from the FeatureType
//of the real datastore.
//boolean createAttrDTO = (featureTypeDTO.getSchemaAttributes().size() == 0);
LOGGER.fine("loading datastore " + typeName);
boolean createAttrDTO;
if (featureTypeDTO.getSchemaAttributes() == null) {
createAttrDTO = true;
} else {
createAttrDTO = featureTypeDTO.getSchemaAttributes().size() == 0;
}
if (createAttrDTO) {
List attributeDTOs = createAttrDTOsFromSchema(featureType);
featureTypeDTO.setSchemaAttributes(attributeDTOs);
LOGGER.finer(
"No schema found, setting featureTypeDTO with "
+ attributeDTOs);
} else {
for (int index = 0;
index < featureType.getAttributeCount(); index++) {
AttributeType attrib = featureType.getAttributeType(index);
attributeNames.add(attrib.getName());
ATTRIBUTENames.add(attrib.getName().toUpperCase());
}
if (featureTypeDTO.getSchemaAttributes() != null) {
for (Iterator a = featureTypeDTO.getSchemaAttributes()
.iterator();
a.hasNext();) {
AttributeTypeInfoDTO attribDTO = (AttributeTypeInfoDTO) a
.next();
String attributeName = attribDTO.getName();