This project has retired. For details please refer to its
Attic page.
DefaultKeyGenerator xref
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.juddi.keygen;
19
20 import java.util.Iterator;
21 import java.util.List;
22 import java.util.UUID;
23
24 import org.apache.commons.configuration.ConfigurationException;
25 import org.apache.juddi.config.AppConfig;
26 import org.apache.juddi.config.Property;
27 import org.apache.juddi.model.UddiEntityPublisher;
28 import org.apache.juddi.v3.client.UDDIConstants;
29 import org.apache.juddi.v3.error.ErrorMessage;
30 import org.apache.juddi.v3.error.FatalErrorException;
31 import org.uddi.v3_service.DispositionReportFaultMessage;
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47 public class DefaultKeyGenerator implements KeyGenerator {
48
49 public String generate(UddiEntityPublisher publisher) throws DispositionReportFaultMessage {
50 String domain = getDomain(publisher);
51 if (domain==null) {
52 String rootPartition = "";
53 try
54 { rootPartition = AppConfig.getConfiguration().getString(Property.JUDDI_ROOT_PARTITION); }
55 catch(ConfigurationException ce)
56 { throw new FatalErrorException(new ErrorMessage("errors.configuration.Retrieval", Property.JUDDI_ROOT_PARTITION));}
57 domain = rootPartition;
58 }
59 return domain + PARTITION_SEPARATOR + UUID.randomUUID();
60 }
61
62 public static String getDomain(UddiEntityPublisher publisher) {
63 String domain = null;
64 if (publisher==null || "uddi".equalsIgnoreCase(publisher.getAuthorizedName())) return domain;
65 List<String> domains = publisher.getKeyGeneratorKeys();
66 if (domains!=null && !domains.isEmpty()) {
67 Iterator<String> iter = domains.iterator();
68 int partsMax = 1000;
69
70 while (iter.hasNext()) {
71 String thisDomain = iter.next();
72 String[] parts = thisDomain.split(":");
73 if ((domain == null || (2 <= parts.length && parts.length < partsMax)) && thisDomain.length() + 37 < 255) {
74 partsMax = parts.length;
75 domain = thisDomain;
76 }
77 }
78 domain = domain.substring(0, domain.lastIndexOf(":"));
79 }
80 return domain;
81 }
82
83 }