1
14
15 package com.liferay.portal.plugin;
16
17 import com.liferay.portal.kernel.util.StringBundler;
18 import com.liferay.portal.kernel.util.StringPool;
19 import com.liferay.portal.kernel.util.Validator;
20
21 import java.util.Iterator;
22 import java.util.Map;
23 import java.util.Set;
24 import java.util.TreeMap;
25
26
31 public class RepositoryReport {
32
33 public static final String SUCCESS = "success";
34
35 public void addSuccess(String repositoryURL) {
36 _reportMap.put(repositoryURL, SUCCESS);
37 }
38
39 public void addError(String repositoryURL, PluginPackageException ppe) {
40 StringBundler sb = new StringBundler(3);
41
42 if (Validator.isNotNull(ppe.getMessage())) {
43 sb.append(ppe.getMessage());
44 }
45
46 if ((ppe.getCause() != null) &&
47 Validator.isNull(ppe.getCause().getMessage())) {
48
49 sb.append(ppe.getCause().getMessage());
50 }
51
52 if (sb.length() == 0) {
53 sb.append(ppe.toString());
54 }
55
56 _reportMap.put(repositoryURL, sb.toString());
57 }
58
59 public Set<String> getRepositoryURLs() {
60 return _reportMap.keySet();
61 }
62
63 public String getState(String repositoryURL) {
64 return _reportMap.get(repositoryURL);
65 }
66
67 public String toString() {
68 Iterator<String> itr = getRepositoryURLs().iterator();
69
70 if (getRepositoryURLs().isEmpty()) {
71 return StringPool.BLANK;
72 }
73
74 StringBundler sb = new StringBundler(getRepositoryURLs().size() * 3);
75
76 while (itr.hasNext()) {
77 String repositoryURL = itr.next();
78
79 sb.append(repositoryURL);
80 sb.append(": ");
81 sb.append(_reportMap.get(repositoryURL));
82 }
83
84 return sb.toString();
85 }
86
87 private Map<String, String> _reportMap = new TreeMap<String, String>();
88
89 }