Skip to content

Commit

Permalink
Merge pull request #294 in ZX/zextras from bugfix/ZX-2733-zimlet-norm…
Browse files Browse the repository at this point in the history
…alizer-explode to release/1.9.1

* commit 'ed23252ce78a82c20ae59611eff696dafc58a8a6':
  ZX-2733 ZAL: Now Provisioning.getZimlet() now throws an exception if the zimlet is null.
  ZX-2733 ZxCore: Zimlet are now normalized correctly even when one of them doesn't have a priority.
  • Loading branch information
ZeXtrasJay committed Sep 11, 2014
2 parents 0460396 + f59492b commit 198badd
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/java/org/openzal/zal/Provisioning.java
Expand Up @@ -581,7 +581,7 @@ public List<Domain> getAllDomains()
}
}

@Nullable
@NotNull
public Zimlet getZimlet(String zimletName)
throws ZimbraException
{
Expand All @@ -590,7 +590,7 @@ public Zimlet getZimlet(String zimletName)
com.zimbra.cs.account.Zimlet zimlet = mProvisioning.getZimlet(zimletName);
if (zimlet == null)
{
return null;
throw ExceptionWrapper.createNoSuchZimletException("Zimlet " + zimletName + " not found.");
}
else
{
Expand All @@ -599,7 +599,7 @@ public Zimlet getZimlet(String zimletName)
}
catch (com.zimbra.common.service.ServiceException e)
{
throw ExceptionWrapper.wrap(e);
throw ExceptionWrapper.createNoSuchZimletException(e);
}
}

Expand Down
15 changes: 13 additions & 2 deletions src/java/org/openzal/zal/Utils.java
Expand Up @@ -52,6 +52,7 @@
import javax.mail.MessagingException;
import javax.mail.Session;
import java.io.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

Expand Down Expand Up @@ -117,11 +118,21 @@ public static String encode(Map<String, Object> attrs)
@Nullable
public static List<Zimlet> orderZimletsByPriority(List<Zimlet> zimlets)
{
List<com.zimbra.cs.account.Zimlet> zimbraZimletList =
new ArrayList<com.zimbra.cs.account.Zimlet>(zimlets.size());

for (Zimlet zimlet : zimlets)
{
zimlet.getPriority();
zimbraZimletList.add(zimlet.toZimbra());
}
return null;

List<Zimlet> orderedZimletList = new ArrayList<Zimlet>(zimlets.size());
for (com.zimbra.cs.account.Zimlet zimlet : ZimletUtil.orderZimletsByPriority(zimbraZimletList))
{
orderedZimletList.add(new Zimlet(zimlet));
}

return orderedZimletList;
}

public static String getPublicURLForDomain(Server server, Domain domain, String path)
Expand Down
14 changes: 14 additions & 0 deletions src/java/org/openzal/zal/exceptions/ExceptionWrapper.java
Expand Up @@ -351,4 +351,18 @@ public static UnableToObtainDBConnectionException createUnableToObtainDBConnecti
{
throw new UnableToObtainDBConnectionException(e);
}

public static NoSuchZimletException createNoSuchZimletException(
com.zimbra.common.service.ServiceException e
)
{
throw new NoSuchZimletException(e);
}

public static NoSuchZimletException createNoSuchZimletException(
String msg
)
{
throw new NoSuchZimletException(msg);
}
}
@@ -0,0 +1,7 @@
package org.openzal.zal.exceptions;

public class NoSuchZimletException extends ZimbraException
{
public NoSuchZimletException(Exception exception) {super(exception);}
public NoSuchZimletException(String msg) {super(msg);}
}
1 change: 1 addition & 0 deletions tests/java/org/openzal/zal/ProvisioningSimulator.java
Expand Up @@ -234,6 +234,7 @@ public List<Domain> getAllDomains()
throw new RuntimeException("Provisioning method not implemented");
}

@NotNull
public Zimlet getZimlet(String zimletName)
throws ZimbraException
{
Expand Down

0 comments on commit 198badd

Please sign in to comment.