@Override
  public void setRootLocation(String newRootPath) throws MetaException {

    String oldRootPath = partitionSpec.getRootPath();

    if (oldRootPath == null) {
      throw new MetaException("No common root-path. Can't replace root-path!");
    }

    if (newRootPath == null) {
      throw new MetaException("Root path cannot be null.");
    }

    for (Partition partition : partitionSpec.getPartitionList().getPartitions()) {
      String location = partition.getSd().getLocation();
      if (location.startsWith(oldRootPath)) {
        partition.getSd().setLocation(location.replace(oldRootPath, newRootPath));
      }
      else {
        throw new MetaException("Common root-path not found. Can't replace root-path!");
      }
    }
  }
PartitionSpecProxy implementation that composes a List of Partitions.
standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/partition/spec/PartitionListComposingSpecProxy.java