c3da159e4f1aeac76809aaedacc4bd797c73ef9d
[facebook-utils] / src / main / java / de / juplo / facebook / PageMigratedException.java
1 package de.juplo.facebook;
2
3
4 import java.util.regex.Matcher;
5 import java.util.regex.Pattern;
6
7
8
9 /**
10  *
11  * @author kai
12  */
13 public class PageMigratedException extends OAuthException
14 {
15   private final static Pattern pattern =
16       Pattern.compile("Page ID ([0-9]+) was migrated to page ID ([0-9]+)");
17
18   private final Long oldId, newId;
19
20
21   public PageMigratedException(String message)
22   {
23     super(message, 21);
24     Matcher matcher = pattern.matcher(message);
25     if (!matcher.find())
26       throw new RuntimeException("Could not parse migration-error: " + message);
27     oldId = Long.parseLong(matcher.group(1));
28     newId = Long.parseLong(matcher.group(2));
29   }
30
31
32   public Long getOldId()
33   {
34     return oldId;
35   }
36
37   public Long getNewId()
38   {
39     return newId;
40   }
41 }