@Override
  public boolean unpublishGsCoverageLayer(String workspaceName, String coverageLayer) {

    if (!gsDao.deleteCoverage(workspaceName, coverageLayer)) {
      return false;
    }

    if (!gsDao.deleteGsCoverageStore(workspaceName, coverageLayer)) {
      return false;
    }

    return true;
  }
 /*
  * (non-Javadoc)
  *
  * @see
  * com.emergya.persistenceGeo.service.GeoserverService#deleteGsWorkspace
  * (java.lang.String)
  */
 @Override
 public boolean deleteGsWorkspace(String workspaceName) {
   if (LOG.isInfoEnabled()) {
     LOG.info("Deleting Geoserver workspace [workspaceName=" + workspaceName + "]");
   }
   return gsDao.deleteWorkspace(workspaceName);
 }
 /*
  * (non-Javadoc)
  *
  * @see com.emergya.persistenceGeo.service.GeoserverService#unpublishGsLayer
  * (boolean)
  */
 @Override
 public boolean unpublishGsDbLayer(String workspaceName, String layerName) {
   if (LOG.isInfoEnabled()) {
     LOG.info("Unpublishig geoserver layer");
   }
   boolean result = false;
   result =
       gsDao.deletePostgisFeatureType(workspaceName, workspaceName + DATASTORE_SUFFIX, layerName);
   return result;
 }
  /*
   * (non-Javadoc)
   *
   * @see com.emergya.persistenceGeo.service.GeoserverService#
   * createGsWorkspaceWithDatastore(java.lang.String)
   */
  @Override
  public boolean createGsWorkspaceWithDatastore(String workspaceName) {
    if (LOG.isInfoEnabled()) {
      LOG.info("Creating Geoserver workspace [workspaceName=" + workspaceName + "]");
    }
    boolean result = false;
    String nsUrl;
    if (this.namespaceBaseUrl.endsWith("/")) {
      nsUrl = this.namespaceBaseUrl + workspaceName;
    } else {
      nsUrl = this.namespaceBaseUrl + "/" + workspaceName;
    }
    URI uri;
    try {
      uri = new URI(nsUrl);
      result = gsDao.createNamespace(workspaceName, uri);

      if (!result) {
        // Can't create Namespace. Stop here.
        if (LOG.isInfoEnabled()) {
          LOG.info(
              "Couln't create the namespace and his asocciated "
                  + "workspace [workspaceName="
                  + workspaceName
                  + "]");
        }
        return result;
      }
      String datastoreName = workspaceName + DATASTORE_SUFFIX;
      result = gsDao.createDatastoreJndi(workspaceName, datastoreName);
      if (!result) {
        // Can't create Datastore. Try to delete workspace.
        if (LOG.isInfoEnabled()) {
          LOG.info(
              "Couln't create the datastore "
                  + datastoreName
                  + " in workspace "
                  + workspaceName
                  + ". Trying to delete workspace...");
        }
        boolean deleteResult = gsDao.deleteWorkspace(workspaceName);

        if (LOG.isInfoEnabled()) {
          if (deleteResult) {
            LOG.info("Workspace " + workspaceName + " successfully deleted");
          } else {
            LOG.warn("Couldn't delete workspace " + workspaceName);
          }
        }
      }

    } catch (URISyntaxException e) {
      throw new GeoserverException(
          "Illegal URL syntax detected when"
              + "preparing for creating a geoserver workspace [URI="
              + nsUrl
              + "]",
          e);
    }

    return result;
  }
 @Override
 public boolean deleteStyle(String styleName) {
   return gsDao.deleteStyle(styleName);
 }
  @Override
  public boolean setLayerStyle(String workspaceName, String layerName, String newLayerStyleName) {

    return gsDao.setLayerStyle(workspaceName, layerName, newLayerStyleName);
  }
  @Override
  public boolean copyLayerStyle(String sourceLayerName, String newStyleName) {
    String layerSDLContent = gsDao.getLayerStyle(sourceLayerName);

    return gsDao.createStyle(newStyleName, layerSDLContent);
  }
 @Override
 public GsCoverageDetails getCoverageDetails(
     String workspaceName, String coverageStore, String coverageName) {
   return gsDao.getCoverageDetails(workspaceName, coverageStore, coverageName);
 }
 @Override
 public GsCoverageStoreData getCoverageStoreData(String workspaceName, String coverageStoreName) {
   return gsDao.getCoverageStoreData(workspaceName, coverageStoreName);
 }
  @Override
  public boolean publishWorldImage(
      String workspaceName, String storeName, File imageFile, String crs) {

    return gsDao.publishWorldImage(workspaceName, storeName, imageFile, crs);
  }
 @Override
 public boolean publishGeoTIFF(String workspace, String storeName, File geotiff, String crs) {
   return gsDao.publishGeoTIFF(workspace, storeName, geotiff, crs);
 }
 /*
  * (non-Javadoc)
  *
  * @see
  * com.emergya.persistenceGeo.service.GeoserverService#createDatastoreJndi
  * (java.lang.String, java.lang.String)
  */
 @Override
 public boolean createDatastoreJndi(String workspaceName, String datastoreName) {
   return gsDao.createDatastoreJndi(workspaceName, datastoreName);
 }
 /*
  * (non-Javadoc)
  *
  * @see
  * com.emergya.persistenceGeo.service.GeoserverService#existsLayerInWorkspace
  * (java.lang.String, java.lang.String)
  */
 @Override
 public boolean existsLayerInWorkspace(String layerName, String workspaceName) {
   return gsDao.existsLayerInWorkspace(layerName, workspaceName);
 }
  /*
   * (non-Javadoc)
   *
   * @see
   * com.emergya.persistenceGeo.service.GeoserverService#publishGsDbLayer()
   */
  @Override
  public boolean publishGsDbLayer(
      String workspaceName,
      String tableName,
      String layerName,
      String title,
      BoundingBox nativeBoundingBox,
      GeometryType geomType) {
    if (LOG.isInfoEnabled()) {
      LOG.info(
          "Publising geoserver database layer [workspaceName="
              + workspaceName
              + ", tableName="
              + tableName
              + ", layerName="
              + layerName
              + ", geometryType="
              + geomType
              + "]");
    }
    boolean result = false;

    // Transform native bounding box to EPSG:4326
    String nativeSrs = nativeBoundingBox.getSrs();
    BoundingBox declaredBBox = new BoundingBox();
    declaredBBox.setSrs(DEFAULT_SRS);
    boolean declaredSrsTransformed = false;
    try {
      CoordinateReferenceSystem nativeCRS = CRS.decode(nativeSrs);
      CoordinateReferenceSystem targetCRS = CRS.decode(DEFAULT_SRS);
      MathTransform transform = CRS.findMathTransform(nativeCRS, targetCRS);
      double[] sourceCoords = new double[4];
      double[] coordTransformed = new double[4];

      // Fill the array with the bounding box
      sourceCoords[0] = nativeBoundingBox.getMinx();
      sourceCoords[1] = nativeBoundingBox.getMiny();
      sourceCoords[2] = nativeBoundingBox.getMaxx();
      sourceCoords[3] = nativeBoundingBox.getMaxy();
      transform.transform(sourceCoords, 0, coordTransformed, 0, 2);

      declaredBBox.setMinx(coordTransformed[0]);
      declaredBBox.setMiny(coordTransformed[1]);
      declaredBBox.setMaxx(coordTransformed[2]);
      declaredBBox.setMaxy(coordTransformed[3]);
      declaredSrsTransformed = true;

    } catch (NoSuchAuthorityCodeException e) {
      LOG.error(
          "No se ha encontrado la autoridad especificada en el Sistema de Referencia Nativo", e);
    } catch (FactoryException e) {
      LOG.error("No se ha podido crear la factoría de SRS en GeoserverServiceImpl", e);
    } catch (TransformException e) {
      LOG.error(
          "Error transformando las coordenadas del nativo al delcarado. Se usará como declarado el mismo que el nativo",
          e);
    }

    GsFeatureDescriptor fd = new GsFeatureDescriptor();
    fd.setNativeName(tableName);
    fd.setTitle(title);
    fd.setName(layerName);
    if (nativeBoundingBox != null) {
      if (declaredSrsTransformed) {
        fd.setLatLonBoundingBox(declaredBBox);

        // this is not an error. You should assign the native SRS to the
        // declared SRS.
        fd.setSRS(nativeBoundingBox.getSrs());
      }
      fd.setNativeCRS(nativeBoundingBox.getSrs());
      fd.setNativeBoundingBox(nativeBoundingBox);
    }

    GsLayerDescriptor ld = new GsLayerDescriptor();

    ld.setType(geomType);

    String datastoreName = workspaceName + DATASTORE_SUFFIX;
    result = gsDao.publishPostgisLayer(workspaceName, datastoreName, fd, ld);

    return result;
  }