Пример #1
0
 /**
  * Read an id generated from {@link #toId(FolderPath)} back to a {@link FolderPath}.
  *
  * @return the path or null if the input is null or not readable
  */
 public static FolderPath fromId(String id) {
   FolderPath folderPath;
   if (id == null) {
     folderPath = null;
   } else
     try {
       String pathAsString = new String(Base64.getDecoder().decode(id), StandardCharsets.UTF_8);
       folderPath = FolderPath.deserializeFromString(pathAsString);
     } catch (final NullPointerException
         | IllegalArgumentException e) { // NOSONAR no need to log such an exception
       // TODO: Maybe throwing an exception would be best, something like
       // "InvalidFolderIdException"
       folderPath = null;
     }
   return folderPath;
 }
Пример #2
0
 /**
  * Converts this path to an identifier usable in an URL.
  *
  * @return the Base64 encoding of the String serialization of this path.
  */
 public static String toId(FolderPath folderPath) {
   return new String(
       Base64.getEncoder()
           .encode(folderPath.serializeAsString().getBytes(StandardCharsets.UTF_8)));
 }