Refactored classes in thematically packages
[facebook-errors] / src / main / java / de / juplo / facebook / exceptions / PageMigratedException.java
diff --git a/src/main/java/de/juplo/facebook/exceptions/PageMigratedException.java b/src/main/java/de/juplo/facebook/exceptions/PageMigratedException.java
new file mode 100644 (file)
index 0000000..d327b6d
--- /dev/null
@@ -0,0 +1,41 @@
+package de.juplo.facebook.exceptions;
+
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+
+
+/**
+ *
+ * @author kai
+ */
+public class PageMigratedException extends OAuthException
+{
+  private final static Pattern pattern =
+      Pattern.compile("Page ID ([0-9]+) was migrated to page ID ([0-9]+)");
+
+  private final Long oldId, newId;
+
+
+  public PageMigratedException(String message)
+  {
+    super(message, 21);
+    Matcher matcher = pattern.matcher(message);
+    if (!matcher.find())
+      throw new RuntimeException("Could not parse migration-error: " + message);
+    oldId = Long.parseLong(matcher.group(1));
+    newId = Long.parseLong(matcher.group(2));
+  }
+
+
+  public Long getOldId()
+  {
+    return oldId;
+  }
+
+  public Long getNewId()
+  {
+    return newId;
+  }
+}