예제 #1
0
  private boolean hasRightToPublishBaseLayer(final String layerId, final User user) {

    final long id = ConversionHelper.getLong(layerId.substring(PREFIX_BASELAYER.length()), -1);
    if (id == -1) {
      log.warn("Error parsing layerId:", layerId);
      return false;
    }
    List<Long> list = new ArrayList<Long>();
    list.add(id);
    Map<Long, List<Permissions>> map =
        permissionsService.getPermissionsForBaseLayers(list, Permissions.PERMISSION_TYPE_PUBLISH);
    List<Permissions> permissions = map.get(id);

    boolean hasPermission = false;
    hasPermission =
        permissionsService.permissionGrantedForRolesOrUser(
            user, permissions, Permissions.PERMISSION_TYPE_PUBLISH);
    if (!hasPermission) {
      log.warn(
          "User tried to publish layer with no publish permission. LayerID:",
          layerId,
          "- User:",
          user);
    }
    return hasPermission;
  }
예제 #2
0
 private boolean hasRightToPublishMyPlaceLayer(
     final String layerId, final String userUuid, final String publisherName) {
   final long categoryId =
       ConversionHelper.getLong(layerId.substring(PREFIX_MYPLACES.length()), -1);
   if (categoryId == -1) {
     log.warn("Error parsing layerId:", layerId);
     return false;
   }
   final List<Long> publishedMyPlaces = new ArrayList<Long>();
   publishedMyPlaces.add(categoryId);
   final List<MyPlaceCategory> myPlacesLayers =
       myPlaceService.getMyPlaceLayersById(publishedMyPlaces);
   for (MyPlaceCategory place : myPlacesLayers) {
     if (place.getUuid().equals(userUuid)) {
       myPlaceService.updatePublisherName(categoryId, userUuid, publisherName); // make it public
       return true;
     }
   }
   log.warn(
       "Found my places layer in selected that isn't users own or isnt published any more! LayerId:",
       layerId,
       "User UUID:",
       userUuid);
   return false;
 }