@PostConstruct
 void init() throws SldException {
   if (getDirectory() != null) {
     try {
       if (getDirectory().getFile().exists()) {
         if (getDirectory().getFile().isDirectory()) {
           File[] sldFiles =
               getDirectory()
                   .getFile()
                   .listFiles(
                       new FilenameFilter() {
                         public boolean accept(File dir, String name) {
                           return name.endsWith(".sld") || name.endsWith(".xml");
                         }
                       });
           for (File file : sldFiles) {
             RawSld raw = new RawSld();
             raw.setXml(FileUtils.readFileToString(file, FILE_ENCODING));
             String fileName = StringUtils.stripFilenameExtension(file.getName());
             StyledLayerDescriptorInfo tmp = parseXml(fileName, raw.getXml());
             raw.setName(fileName);
             raw.setTitle(tmp.getTitle());
             raw.setVersion(tmp.getVersion());
             log.info("added sld '{}' to service", fileName);
             allSlds.put(raw.getName(), raw);
           }
         }
       }
     } catch (Exception e) { // NOSONAR
       log.warn("Error while initilizing SLD service.", e);
     }
   }
 }
 /**
  * Convert raw xml to StyledLayerDescriptorInfo.
  *
  * @param sld
  * @return StyledLayerDescriptorInfo
  * @throws SldException
  */
 public StyledLayerDescriptorInfo toSldI(RawSld sld) throws SldException {
   try {
     return parseXml(sld.getName(), sld.getXml());
   } catch (JiBXException e) {
     throw new SldException("Validation error", e);
   }
 }
 /**
  * Test by unmarshalling.
  *
  * @param sld
  * @throws SldException
  */
 public boolean validate(RawSld sld) throws SldException {
   try {
     parseXml("", sld.getXml());
     return true;
   } catch (JiBXException e) {
     return false;
   }
 }