diff --git a/pom.xml b/pom.xml
index f465f51..b45f98b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -10,9 +10,9 @@
jar
- 4.32.0
+ 4.32.0.avoid-reflection-in-zal
-SNAPSHOT
- 4.28.0
+ 4.28.1.avoid-reflection-in-zal-SNAPSHOT
UTF-8
2.15.4
1.0.15
@@ -706,39 +706,6 @@
-
- com.coderplus.maven.plugins
- copy-rename-maven-plugin
- 1.0.1
-
-
- rename-DataExtractor
- compile
-
- copy
-
-
-
- ${project.build.directory}/classes/com/zimbra/cs/redolog/op/DataExtractor.class
-
- ${project.build.directory}/classes/com/zimbra/cs/redolog/op/DataExtractor
-
-
-
- rename-VolumeBlobProxy
- compile
-
- copy
-
-
-
- ${project.build.directory}/classes/com/zimbra/cs/store/file/VolumeBlobProxy.class
-
- ${project.build.directory}/classes/com/zimbra/cs/store/file/VolumeBlobProxy
-
-
-
-
org.apache.maven.plugins
maven-source-plugin
@@ -778,10 +745,6 @@
org.openzal.zal.extension.ZalEntrypointImpl
-
- com/zimbra/cs/redolog/op/DataExtractor.class
- com/zimbra/cs/store/file/VolumeBlobProxy.class
-
diff --git a/src/main/java/org/openzal/zal/BlobWrap.java b/src/main/java/org/openzal/zal/BlobWrap.java
index 4285831..4824c48 100644
--- a/src/main/java/org/openzal/zal/BlobWrap.java
+++ b/src/main/java/org/openzal/zal/BlobWrap.java
@@ -20,7 +20,7 @@
package org.openzal.zal;
-import com.zimbra.cs.store.file.VolumeBlobProxy;
+import com.zimbra.cs.store.file.VolumeBlob;
import com.zimbra.cs.store.file.VolumeMailboxBlob;
import com.zimbra.cs.store.file.VolumeStagedBlob;
import javax.annotation.Nonnull;
@@ -55,9 +55,9 @@ public BlobWrap(
{
throw new RuntimeException("Cannot handle blob of type " + blob.getClass());
}
- if (VolumeBlobProxy.isVolumeBlob(blob))
+ if (VolumeBlobUtils.isVolumeBlob(blob))
{
- volumeId = String.valueOf(new VolumeBlobProxy(blob).getVolumeId());
+ volumeId = String.valueOf(new VolumeBlob((VolumeBlob) blob).getVolumeId());
}
mVolumeId = volumeId;
@@ -133,8 +133,7 @@ public BlobWrap setSize(long size)
}
@Override
- public long getStoredFileSize() throws IOException
- {
+ public long getStoredFileSize() {
return mBlob.getFile().length();
}
diff --git a/src/main/java/org/openzal/zal/Flag.java b/src/main/java/org/openzal/zal/Flag.java
index 2702fb6..3d36d4e 100644
--- a/src/main/java/org/openzal/zal/Flag.java
+++ b/src/main/java/org/openzal/zal/Flag.java
@@ -20,9 +20,7 @@
package org.openzal.zal;
-import java.lang.reflect.*;
-import org.openzal.zal.log.ZimbraLog;
import javax.annotation.Nonnull;
@@ -68,40 +66,9 @@ public final class Flag extends Item
public static int BITMASK_ARCHIVED = com.zimbra.cs.mailbox.Flag.BITMASK_ARCHIVED;
public static int BITMASK_IN_DUMPSTER = com.zimbra.cs.mailbox.Flag.BITMASK_IN_DUMPSTER;
- private static Method sFlagOf;
-
- static
- {
- try
- {
- Class partypes[] = new Class[1];
- partypes[0] = int.class;
-
- sFlagOf = com.zimbra.cs.mailbox.Flag.FlagInfo.class.getDeclaredMethod("of", partypes);
- sFlagOf.setAccessible(true);
- }
- catch (Throwable ex)
- {
- ZimbraLog.extensions.fatal("ZAL Reflection Initialization Exception: " + Utils.exceptionToString(ex));
- throw new RuntimeException(ex);
- }
- }
-
-
static com.zimbra.cs.mailbox.Flag.FlagInfo of(int id)
{
- try
- {
- Object parameters[] = new Object[1];
- parameters[0] = id;
-
- return (com.zimbra.cs.mailbox.Flag.FlagInfo) sFlagOf.invoke(null, parameters);
- }
- catch (Throwable ex)
- {
- ZimbraLog.extensions.fatal("ZAL Reflection Initialization Exception: " + Utils.exceptionToString(ex));
- throw new RuntimeException(ex);
- }
+ return com.zimbra.cs.mailbox.Flag.FlagInfo.of(id);
}
public static int BITMASK_FROM_ME = com.zimbra.cs.mailbox.Flag.BITMASK_FROM_ME;
diff --git a/src/main/java/org/openzal/zal/InternalOverrideBlobWithMailboxInfo.java b/src/main/java/org/openzal/zal/InternalOverrideBlobWithMailboxInfo.java
index 3ad7c23..b4b0f1d 100644
--- a/src/main/java/org/openzal/zal/InternalOverrideBlobWithMailboxInfo.java
+++ b/src/main/java/org/openzal/zal/InternalOverrideBlobWithMailboxInfo.java
@@ -28,14 +28,17 @@
import java.io.IOException;
import java.io.InputStream;
-class InternalOverrideBlobWithMailboxInfo extends com.zimbra.cs.store.file.VolumeBlobProxy
+import static org.openzal.zal.VolumeBlobUtils.VOLUME_BLOB_DEFAULT_FILE;
+import static org.openzal.zal.VolumeBlobUtils.VOLUME_BLOB_DEFAULT_VOLUME_ID;
+
+class InternalOverrideBlobWithMailboxInfo extends com.zimbra.cs.store.file.VolumeBlob
{
private final Blob mBlob;
private final String mVolumeId;
public InternalOverrideBlobWithMailboxInfo(Blob blob)
{
- super();
+ super(VOLUME_BLOB_DEFAULT_FILE, VOLUME_BLOB_DEFAULT_VOLUME_ID);
mBlob = blob;
mVolumeId = blob.getVolumeId();
}
diff --git a/src/main/java/org/openzal/zal/InternalOverrideVolumeBlob.java b/src/main/java/org/openzal/zal/InternalOverrideVolumeBlob.java
index 6f6abb3..87c2c22 100644
--- a/src/main/java/org/openzal/zal/InternalOverrideVolumeBlob.java
+++ b/src/main/java/org/openzal/zal/InternalOverrideVolumeBlob.java
@@ -20,7 +20,7 @@
package org.openzal.zal;
-import com.zimbra.cs.store.file.VolumeBlobProxy;
+import com.zimbra.cs.store.file.VolumeBlob;
import org.apache.commons.io.IOUtils;
import java.io.BufferedInputStream;
@@ -29,14 +29,17 @@
import java.io.IOException;
import java.io.InputStream;
-class InternalOverrideVolumeBlob extends VolumeBlobProxy
+import static org.openzal.zal.VolumeBlobUtils.VOLUME_BLOB_DEFAULT_FILE;
+import static org.openzal.zal.VolumeBlobUtils.VOLUME_BLOB_DEFAULT_VOLUME_ID;
+
+class InternalOverrideVolumeBlob extends VolumeBlob
{
private final Blob mBlob;
private final String mVolumeId;
public InternalOverrideVolumeBlob(Blob blob)
{
- super();
+ super(VOLUME_BLOB_DEFAULT_FILE, VOLUME_BLOB_DEFAULT_VOLUME_ID);
mBlob = blob;
mVolumeId = blob.getVolumeId();
}
diff --git a/src/main/java/org/openzal/zal/Item.java b/src/main/java/org/openzal/zal/Item.java
index 1e7be7a..d721541 100644
--- a/src/main/java/org/openzal/zal/Item.java
+++ b/src/main/java/org/openzal/zal/Item.java
@@ -25,7 +25,6 @@
import com.zimbra.cs.mailbox.MailItem;
import java.io.IOException;
import java.io.InputStream;
-import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -36,7 +35,6 @@
import org.openzal.zal.exceptions.NoSuchFolderException;
import org.openzal.zal.exceptions.ZimbraException;
import org.openzal.zal.lib.ZimbraVersion;
-import org.openzal.zal.log.ZimbraLog;
import org.openzal.zal.lucene.document.Document;
import javax.annotation.Nonnull;
@@ -60,9 +58,6 @@ public class Item implements Comparable-
public static final byte TYPE_MOUNTPOINT = 13;
public static final byte TYPE_CHAT = 16;
- // FIXME clone of Item.UnderlyingData.FIELD_INDEX_ID
- public static final String FN_INDEX_ID = "idx";
-
public Item(Object item)
{
mMailItem = (MailItem) Objects.requireNonNull(item);
@@ -115,10 +110,10 @@ public static Item constructItem(@Nonnull Mailbox mbox, @Nonnull UnderlyingData
try
{
return new Item(
- MailItem.constructItem(
- mbox.toZimbra(com.zimbra.cs.mailbox.Mailbox.class),
- data.toZimbra(MailItem.UnderlyingData.class)
- )
+ MailItem.constructItem(
+ mbox.toZimbra(com.zimbra.cs.mailbox.Mailbox.class),
+ data.toZimbra(MailItem.UnderlyingData.class)
+ )
);
}
catch (com.zimbra.common.service.ServiceException e)
@@ -129,16 +124,16 @@ public static Item constructItem(@Nonnull Mailbox mbox, @Nonnull UnderlyingData
@Nonnull
public static Item constructItem(@Nonnull Mailbox mbox, @Nonnull UnderlyingData data, boolean skipCache)
- throws ZimbraException
+ throws ZimbraException
{
try
{
return new Item(
- MailItem.constructItem(
- mbox.toZimbra(com.zimbra.cs.mailbox.Mailbox.class),
- data.toZimbra(MailItem.UnderlyingData.class),
- skipCache
- )
+ MailItem.constructItem(
+ mbox.toZimbra(com.zimbra.cs.mailbox.Mailbox.class),
+ data.toZimbra(MailItem.UnderlyingData.class),
+ skipCache
+ )
);
}
catch( com.zimbra.common.service.ServiceException e )
@@ -155,7 +150,7 @@ public Mailbox getMailbox()
public int getMailboxId()
{
- return (int) mMailItem.getMailboxId();
+ return mMailItem.getMailboxId();
}
public String getDigest()
@@ -291,7 +286,7 @@ public String getBlobPath() throws IOException
public static class CustomMetadata
{
- private MailItem.CustomMetadata mCustomMetadata;
+ private final MailItem.CustomMetadata mCustomMetadata;
public CustomMetadata(Object meta)
{
@@ -381,7 +376,7 @@ public static class UnderlyingData
public static final String FN_MOD_CONTENT = "modc";
public static final String FN_DATE_CHANGED = "dc";
- private MailItem.UnderlyingData mUnderlyingData;
+ private final MailItem.UnderlyingData mUnderlyingData;
public UnderlyingData()
{
@@ -407,7 +402,7 @@ public UnderlyingData(Metadata metadata)
}
public void deserialize(Metadata metadata)
- throws ServiceException
+ throws ServiceException
{
mUnderlyingData.deserialize(metadata.toZimbra(com.zimbra.cs.mailbox.Metadata.class));
}
@@ -549,7 +544,7 @@ public static class Color
public static final Color RED = new Color(0xFF0000L);
public static final Color YELLOW = new Color(0xFFFF00L);
- private com.zimbra.common.mailbox.Color mColor;
+ private final com.zimbra.common.mailbox.Color mColor;
public Color(Object color)
{
@@ -602,7 +597,7 @@ public String getName()
}
public String getPath()
- throws ZimbraException
+ throws ZimbraException
{
try
{
@@ -625,7 +620,7 @@ public int getParentId()
}
public InputStream getContentStream()
- throws ZimbraException
+ throws ZimbraException
{
try
{
@@ -638,7 +633,7 @@ public InputStream getContentStream()
}
public byte[] getContent()
- throws ZimbraException
+ throws ZimbraException
{
try
{
@@ -695,7 +690,7 @@ public String toString()
}
public boolean inTrash()
- throws NoSuchFolderException
+ throws NoSuchFolderException
{
try
{
@@ -727,121 +722,33 @@ public boolean isUnread()
return mMailItem.isUnread();
}
- private static Method sDeserializeMethod;
-
- static
- {
- try
- {
- Class partypes[] = new Class[1];
- partypes[0] = com.zimbra.cs.mailbox.Metadata.class;
-
- sDeserializeMethod = MailItem.UnderlyingData.class.getDeclaredMethod("deserialize", partypes);
- sDeserializeMethod.setAccessible(true);
- }
- catch (Throwable ex)
- {
- ZimbraLog.extensions.fatal("ZAL Reflection Initialization Exception: " + Utils.exceptionToString(ex));
- throw new RuntimeException(ex);
- }
- }
-
@Nonnull
public static UnderlyingData decodeZimbraMetadata(@Nullable ZimbraVersion originVersion, final String encodedString)
- throws ZimbraException
+ throws ZimbraException
{
- try
- {
- Metadata meta = new Metadata(encodedString);
-
- UnderlyingData underlyingData = new UnderlyingData();
- Object parameters[] = new Object[1];
- parameters[0] = meta.toZimbra(com.zimbra.cs.mailbox.Metadata.class);
+ Metadata meta = new Metadata(encodedString);
- sDeserializeMethod.invoke(
- underlyingData.toZimbra(MailItem.UnderlyingData.class),
- parameters
- );
+ UnderlyingData underlyingData = new UnderlyingData();
+ try {
+ com.zimbra.cs.mailbox.Metadata metadata = meta.toZimbra(com.zimbra.cs.mailbox.Metadata.class);
+ underlyingData.toZimbra(MailItem.UnderlyingData.class).deserialize(metadata);
return underlyingData;
- }
- catch (Throwable ex)
- {
- throw new RuntimeException(ex);
- }
- }
-
- private static Method sSerializeMethod;
-
- static
- {
- try
- {
- Class partypes[] = new Class[0];
- sSerializeMethod = MailItem.UnderlyingData.class.getDeclaredMethod("serialize", partypes);
- sSerializeMethod.setAccessible(true);
- }
- catch (Throwable ex)
- {
- ZimbraLog.extensions.fatal("ZAL Reflection Initialization Exception: " + Utils.exceptionToString(ex));
- throw new RuntimeException(ex);
+ } catch (ServiceException e) {
+ throw ExceptionWrapper.wrap(e);
}
}
@Nullable
public String encodeZimbraMetadata()
{
- try
- {
- UnderlyingData underlyingData = getUnderlyingData();
- Object parameters[] = new Object[0];
- com.zimbra.cs.mailbox.Metadata meta = (com.zimbra.cs.mailbox.Metadata) sSerializeMethod.invoke(
- underlyingData.toZimbra(MailItem.UnderlyingData.class),
- parameters
- );
- return meta.toString();
- }
- catch (Throwable ex)
- {
- ZimbraLog.mailbox.warn("Exception: " + Utils.exceptionToString(ex));
- return null;
- }
- }
-
- private static Method sEncodeMetadata;
-
- static
- {
- try
- {
- Class partypes[] = {com.zimbra.cs.mailbox.Metadata.class};
-
- sEncodeMetadata = MailItem.class.getDeclaredMethod("encodeMetadata", partypes);
- sEncodeMetadata.setAccessible(true);
- }
- catch (Throwable ex)
- {
- ZimbraLog.extensions.fatal("ZAL Reflection Initialization Exception: " + Utils.exceptionToString(ex));
- throw new RuntimeException(ex);
- }
+ UnderlyingData underlyingData = getUnderlyingData();
+ return underlyingData.toZimbra(MailItem.UnderlyingData.class).serialize().toString();
}
@Nullable
public String encodeSubmetadataForItemType()
{
- try
- {
- Object parameters[] = { new com.zimbra.cs.mailbox.Metadata() };
- com.zimbra.cs.mailbox.Metadata meta = (com.zimbra.cs.mailbox.Metadata) sEncodeMetadata.invoke(
- mMailItem,
- parameters
- );
- return meta.toString();
- }
- catch (Throwable ex)
- {
- ZimbraLog.mailbox.warn("Exception: " + Utils.exceptionToString(ex));
- return null;
- }
+ return mMailItem.encodeMetadata(new com.zimbra.cs.mailbox.Metadata()).toString();
}
public String[] getTags()
diff --git a/src/main/java/org/openzal/zal/Mailbox.java b/src/main/java/org/openzal/zal/Mailbox.java
index 5123a84..b1555c4 100644
--- a/src/main/java/org/openzal/zal/Mailbox.java
+++ b/src/main/java/org/openzal/zal/Mailbox.java
@@ -22,8 +22,6 @@
import com.zimbra.common.service.ServiceException;
import com.zimbra.common.soap.SoapProtocol;
-import com.zimbra.common.util.Pair;
-import com.zimbra.cs.db.DbMailItem;
import com.zimbra.cs.db.DbMailbox;
import com.zimbra.cs.db.DbPool;
import com.zimbra.cs.fb.FreeBusyQuery;
@@ -39,17 +37,11 @@
import com.zimbra.cs.mailbox.Mailbox.DeleteBlobs;
import com.zimbra.cs.mailbox.calendar.RecurId;
import com.zimbra.cs.mailbox.util.TypedIdList;
-import com.zimbra.cs.redolog.RedoLogManager;
-import com.zimbra.cs.redolog.op.SetConfig;
import com.zimbra.cs.service.FileUploadServlet.Upload;
import com.zimbra.cs.service.mail.ItemActionHelper;
import com.zimbra.cs.service.util.ItemId;
import com.zimbra.cs.session.Session;
-import java.util.Objects;
import org.apache.commons.dbutils.DbUtils;
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-
import org.openzal.zal.calendar.CalendarItemData;
import org.openzal.zal.calendar.Invite;
import org.openzal.zal.calendar.RecurrenceId;
@@ -67,14 +59,14 @@
import org.openzal.zal.lib.ZimbraConnectionWrapper;
import org.openzal.zal.lib.ZimbraDatabase;
import org.openzal.zal.log.ZimbraLog;
+import org.openzal.zal.redolog.RedoLogProvider;
+import org.openzal.zal.redolog.op.RawSetConfig;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
import javax.mail.internet.MimeMessage;
-import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.lang.reflect.Field;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -88,20 +80,14 @@
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
import java.util.Set;
-import org.openzal.zal.redolog.RedoLogProvider;
-import org.openzal.zal.redolog.op.RawSetConfig;
-
-//import com.zimbra.cs.fb.FreeBusy;
-
-
public class Mailbox
{
@Nonnull final private com.zimbra.cs.mailbox.Mailbox mMbox;
@Nonnull private final MailboxIndex mIndex;
- public static final int ID_AUTO_INCREMENT = com.zimbra.cs.mailbox.Mailbox.ID_AUTO_INCREMENT;
public static final int ID_FOLDER_USER_ROOT = com.zimbra.cs.mailbox.Mailbox.ID_FOLDER_USER_ROOT;
public static final int ID_FOLDER_INBOX = com.zimbra.cs.mailbox.Mailbox.ID_FOLDER_INBOX;
public static final int ID_FOLDER_TRASH = com.zimbra.cs.mailbox.Mailbox.ID_FOLDER_TRASH;
@@ -117,34 +103,12 @@ public class Mailbox
public static final int ID_FOLDER_AUTO_CONTACTS = com.zimbra.cs.mailbox.Mailbox.ID_FOLDER_AUTO_CONTACTS;
public static final int ID_FOLDER_IM_LOGS = com.zimbra.cs.mailbox.Mailbox.ID_FOLDER_IM_LOGS;
public static final int ID_FOLDER_COMMENTS = 17;
- public static final int ID_FOLDER_PROFILE = 18;
private static final int HIGHEST_SYSTEM_ID = com.zimbra.cs.mailbox.Mailbox.HIGHEST_SYSTEM_ID;
public static final int FIRST_USER_ID = com.zimbra.cs.mailbox.Mailbox.FIRST_USER_ID;
private static final Set CREATE_CALENDAR_ITEM_ALLOWED_METHODS = new HashSet<>(Arrays.asList("PUBLISH", "REQUEST"));
- private static Method sCreateDefaultFlags;
-
- static
- {
- try
- {
- sCreateDefaultFlags = com.zimbra.cs.mailbox.Mailbox.class.getDeclaredMethod("createDefaultFlags");
- sCreateDefaultFlags.setAccessible(true);
- }
- catch (Throwable ex)
- {
- ZimbraLog.extensions.fatal("ZAL Reflection Initialization Exception: " + Utils.exceptionToString(ex));
- throw new RuntimeException(ex);
- }
- }
-
- public MailboxMaintenance getMaintenance()
- {
- return new MailboxMaintenance(mMbox.getMaintenance());
- }
-
public long getSize()
{
return mMbox.getSize();
@@ -170,10 +134,10 @@ public void emptyFolder(@Nonnull OperationContext zContext, int folderId, boolea
public MailboxData getMailboxData()
{
return new MailboxData(
- getId(),
- getSchemaGroupId(),
- getAccountId(),
- getIndexVolume()
+ getId(),
+ getSchemaGroupId(),
+ getAccountId(),
+ getIndexVolume()
);
}
@@ -199,8 +163,8 @@ public FakeMailbox(long id, String accountId, int schemaGroupId)
@Nonnull
private static MailboxData createMailboxMetadata(
- @Nonnull
- com.zimbra.cs.account.Account account
+ @Nonnull
+ com.zimbra.cs.account.Account account
)
{
MailboxData data = new MailboxData();
@@ -218,7 +182,7 @@ private static MailboxData createMailboxMetadata(
data.recentMessages = -1;
data.trackSync = -1;
data.trackImap = false;
- data.configKeys = new HashSet();
+ data.configKeys = new HashSet<>();
return data;
}
@@ -226,7 +190,7 @@ private static MailboxData createMailboxMetadata(
@Nonnull
private static MailboxData createMailboxMetadata(int id, String accountId, int schemaGroupId)
{
- com.zimbra.cs.mailbox.Mailbox.MailboxData data = new com.zimbra.cs.mailbox.Mailbox.MailboxData();
+ MailboxData data = new MailboxData();
data.id = id;
data.schemaGroupId = schemaGroupId;
data.accountId = accountId;
@@ -241,7 +205,7 @@ private static MailboxData createMailboxMetadata(int id, String accountId, int s
data.recentMessages = -1;
data.trackSync = -1;
data.trackImap = false;
- data.configKeys = new HashSet();
+ data.configKeys = new HashSet<>();
return data;
}
@@ -252,10 +216,10 @@ public void migrateContactGroup()
try
{
com.zimbra.cs.mailbox.ContactGroup.MigrateContactGroup contactGroup =
- new com.zimbra.cs.mailbox.ContactGroup.MigrateContactGroup(mMbox);
+ new com.zimbra.cs.mailbox.ContactGroup.MigrateContactGroup(mMbox);
contactGroup.handle();
}
- catch (com.zimbra.common.service.ServiceException ex)
+ catch (ServiceException ex)
{
throw ExceptionWrapper.wrap(ex);
}
@@ -276,7 +240,7 @@ public Mailbox(@Nullable Object mbox)
public static Mailbox createFakeMailbox(@Nonnull Account realAccount)
{
return new Mailbox(
- new FakeMailbox(realAccount.toZimbra(com.zimbra.cs.account.Account.class))
+ new FakeMailbox(realAccount.toZimbra(com.zimbra.cs.account.Account.class))
);
}
@@ -284,7 +248,7 @@ public static Mailbox createFakeMailbox(@Nonnull Account realAccount)
public static Mailbox createFakeMailbox(long id, String accountId, int schemaGroupId)
{
return new Mailbox(
- new FakeMailbox(id, accountId, schemaGroupId)
+ new FakeMailbox(id, accountId, schemaGroupId)
);
}
@@ -297,11 +261,11 @@ public T toZimbra(@Nonnull Class cls)
public OperationContext newZimbraAdminContext()
{
return new OperationContext(
- new com.zimbra.cs.mailbox.OperationContext(
- new ProvisioningImp(
- com.zimbra.cs.account.Provisioning.getInstance()
- ).getZimbraUser().toZimbra(com.zimbra.cs.account.Account.class)
- ,true)
+ new com.zimbra.cs.mailbox.OperationContext(
+ new ProvisioningImp(
+ com.zimbra.cs.account.Provisioning.getInstance()
+ ).getZimbraUser().toZimbra(com.zimbra.cs.account.Account.class)
+ ,true)
);
}
@@ -313,13 +277,13 @@ public com.zimbra.cs.mailbox.Mailbox getMailbox()
@Nonnull
public Account getAccount()
- throws NoSuchAccountException
+ throws NoSuchAccountException
{
try
{
return new Account(mMbox.getAccount());
}
- catch (com.zimbra.common.service.ServiceException serviceException)
+ catch (ServiceException serviceException)
{
throw ExceptionWrapper.wrap(serviceException);
}
@@ -332,7 +296,7 @@ public String getAccountId()
public int getId()
{
- return (int) mMbox.getId();
+ return mMbox.getId();
}
public boolean hasListener(String listenerName)
@@ -351,11 +315,11 @@ public void registerListener(@Nonnull Listener listener)
{
mMbox.addListener(listener.getStoreContext().toZimbra(Session.class));
}
- catch (com.zimbra.common.service.ServiceException e)
+ catch (ServiceException e)
{
ZimbraLog.mailbox.warn("Error adding listener to mailbox " +
- mMbox.getId() + ": " +
- e.getMessage());
+ mMbox.getId() + ": " +
+ e.getMessage());
}
}
@@ -364,11 +328,6 @@ public void unregisterListener(@Nonnull Listener listener)
mMbox.removeListener(listener.getStoreContext().toZimbra(Session.class));
}
- public void unregisterListener(@Nonnull MailboxSessionProxy session)
- {
- mMbox.removeListener(session.toZimbra(Session.class));
- }
-
private static int getMailboxSyncCutoff(@Nonnull com.zimbra.cs.mailbox.Mailbox mMbox)
{
return mMbox.getSyncCutoff();
@@ -382,30 +341,14 @@ public boolean isTombstoneValid(int sequence)
@Nonnull
public Item getItemById(@Nonnull OperationContext zContext, int id, byte type)
- throws NoSuchItemException
+ throws NoSuchItemException
{
MailItem item;
try
{
item = mMbox.getItemById(zContext.getOperationContext(), id, Item.convertType(type));
}
- catch (com.zimbra.common.service.ServiceException serviceException)
- {
- throw ExceptionWrapper.wrap(serviceException);
- }
- return new Item(item);
- }
-
- @Nonnull
- public Item getItemByUuId(@Nonnull OperationContext zContext, String uuid, byte type, boolean fromDumpster)
- throws NoSuchItemException
- {
- MailItem item;
- try
- {
- item = mMbox.getItemByUuid(zContext.getOperationContext(), uuid, Item.convertType(type),fromDumpster);
- }
- catch (com.zimbra.common.service.ServiceException serviceException)
+ catch (ServiceException serviceException)
{
throw ExceptionWrapper.wrap(serviceException);
}
@@ -414,14 +357,14 @@ public Item getItemByUuId(@Nonnull OperationContext zContext, String uuid, byte
@Nonnull
public Item getItemByIdFromDumpster(@Nonnull OperationContext zContext, int id, byte type)
- throws NoSuchItemException
+ throws NoSuchItemException
{
MailItem item;
try
{
item = mMbox.getItemById(zContext.getOperationContext(), id, Item.convertType(type), true);
}
- catch (com.zimbra.common.service.ServiceException serviceException)
+ catch (ServiceException serviceException)
{
throw ExceptionWrapper.wrap(serviceException);
}
@@ -430,50 +373,14 @@ public Item getItemByIdFromDumpster(@Nonnull OperationContext zContext, int id,
@Nonnull
public Item getItemRevisionById(@Nonnull OperationContext zContext, int id, byte type, int revision)
- throws NoSuchItemException
+ throws NoSuchItemException
{
MailItem item;
try
{
item = mMbox.getItemRevision(zContext.getOperationContext(), id, Item.convertType(type), revision);
}
- catch (com.zimbra.common.service.ServiceException serviceException)
- {
- throw ExceptionWrapper.wrap(serviceException);
- }
- if (item == null)
- {
- throw new NoSuchItemException(id+"-"+revision);
- }
- return new Item(item);
- }
-
- @Nullable private static Method sLoadRevisionsMethod = null;
-
- static
- {
- try
- {
- sLoadRevisionsMethod = com.zimbra.cs.mailbox.MailItem.class.getDeclaredMethod("loadRevisions");
- sLoadRevisionsMethod.setAccessible(true);
- }
- catch (Throwable ex)
- {
- ZimbraLog.extensions.fatal("ZAL Reflection Initialization Exception: " + Utils.exceptionToString(ex));
- throw new RuntimeException(ex);
- }
- }
-
- @Nonnull
- public Item getItemRevisionByIdFromDumpster(@Nonnull OperationContext zContext, int id, byte type, int revision)
- throws NoSuchItemException
- {
- MailItem item;
- try
- {
- item = mMbox.getItemRevision(zContext.getOperationContext(), id, Item.convertType(type), revision, true);
- }
- catch (com.zimbra.common.service.ServiceException serviceException)
+ catch (ServiceException serviceException)
{
throw ExceptionWrapper.wrap(serviceException);
}
@@ -520,15 +427,15 @@ public List
- getAllRevisions(@Nonnull OperationContext zContext, int id, by
MailItem mailItem = item.toZimbra(MailItem.class);
List
- revisions;
- Object revisionsObject = sLoadRevisionsMethod.invoke(mailItem);
+ List revisionsObject = mailItem.loadRevisions();
if (revisionsObject == null)
{
revisions = Collections.singletonList(item);
}
else
{
- List zimbraRevisions = (List) revisionsObject;
- revisions = new ArrayList
- (zimbraRevisions.size());
+ List zimbraRevisions = revisionsObject;
+ revisions = new ArrayList<>(zimbraRevisions.size());
for (MailItem zimbraItem : zimbraRevisions)
{
revisions.add(new Item(zimbraItem));
@@ -547,7 +454,7 @@ public List
- getAllRevisions(@Nonnull OperationContext zContext, int id, by
{
List mailItems = mMbox.getAllRevisions(zContext.getOperationContext(), id, Item.convertType(type));
- List
- items = new ArrayList
- (mailItems.size());
+ List
- items = new ArrayList<>(mailItems.size());
for (MailItem mailItem : mailItems)
{
items.add(new Item(mailItem));
@@ -556,19 +463,15 @@ public List
- getAllRevisions(@Nonnull OperationContext zContext, int id, by
return items;
}
}
- catch (com.zimbra.common.service.ServiceException serviceException)
+ catch (ServiceException serviceException)
{
throw ExceptionWrapper.wrap(serviceException);
}
- catch (IllegalAccessException | InvocationTargetException e)
- {
- throw new RuntimeException(e);
- }
}
@Nonnull
public Message getMessageById(@Nonnull OperationContext zContext, int id)
- throws NoSuchMessageException
+ throws NoSuchMessageException
{
try
{
@@ -583,7 +486,7 @@ public Message getMessageById(@Nonnull OperationContext zContext, int id)
@Nonnull
public List getMessagesByConversation(@Nonnull OperationContext zContext, int id)
- throws NoSuchConversationException
+ throws NoSuchConversationException
{
List list;
try
@@ -594,7 +497,7 @@ public List getMessagesByConversation(@Nonnull OperationContext zContex
{
throw ExceptionWrapper.wrap(exception);
}
- List newList = new ArrayList(list.size());
+ List newList = new ArrayList<>(list.size());
for (com.zimbra.cs.mailbox.Message item : list)
{
@@ -604,58 +507,13 @@ public List getMessagesByConversation(@Nonnull OperationContext zContex
return newList;
}
- public void setDate(@Nonnull OperationContext octxt, int itemId, byte type, long date)
- {
- try
- {
- mMbox.setDate(octxt.getOperationContext(), itemId, Item.convertType(type), date);
- }
- catch (com.zimbra.common.service.ServiceException serviceException)
- {
- throw ExceptionWrapper.wrap(serviceException);
- }
- }
-
- @Nonnull
- public List getModifiedTags(@Nonnull OperationContext octxt, int lastSync)
- {
- List list;
- try
- {
- list = mMbox.getModifiedTags(octxt.getOperationContext(), lastSync);
- }
- catch (com.zimbra.common.service.ServiceException e)
- {
- throw ExceptionWrapper.wrap(e);
- }
- List newList = new ArrayList(list.size());
-
- for (MailItem item : list)
- {
- newList.add(new Tag(item));
- }
- return newList;
- }
-
- public List getModifiedItems(@Nonnull OperationContext zContext, int sequence)
- {
- try
- {
- return mMbox.getModifiedItems(zContext.getOperationContext(), sequence).getFirst();
- }
- catch (com.zimbra.common.service.ServiceException e)
- {
- throw ExceptionWrapper.wrap(e);
- }
- }
-
public List listTombstones(int sequence)
{
try
{
return mMbox.getTombstones(sequence).getAllIds();
}
- catch (com.zimbra.common.service.ServiceException serviceException)
+ catch (ServiceException serviceException)
{
throw ExceptionWrapper.wrap(serviceException);
}
@@ -663,14 +521,14 @@ public List listTombstones(int sequence)
@Nonnull
public Folder getFolderByName(@Nonnull OperationContext zContext, String name, int parentId)
- throws NoSuchFolderException
+ throws NoSuchFolderException
{
MailItem folder;
try
{
folder = mMbox.getFolderByName(zContext.getOperationContext(), parentId, name);
}
- catch (com.zimbra.common.service.ServiceException e)
+ catch (ServiceException e)
{
throw ExceptionWrapper.wrap(e);
}
@@ -680,14 +538,14 @@ public Folder getFolderByName(@Nonnull OperationContext zContext, String name, i
@Nonnull
public Folder getFolderByPath(@Nonnull OperationContext zContext, String path)
- throws NoSuchFolderException
+ throws NoSuchFolderException
{
MailItem folder;
try
{
folder = mMbox.getFolderByPath(zContext.getOperationContext(), path);
}
- catch (com.zimbra.common.service.ServiceException e)
+ catch (ServiceException e)
{
throw ExceptionWrapper.wrap(e);
}
@@ -697,18 +555,18 @@ public Folder getFolderByPath(@Nonnull OperationContext zContext, String path)
@Nonnull
public List getFolderList(@Nonnull OperationContext zContext)
- throws NoSuchFolderException
+ throws NoSuchFolderException
{
List folderList = new ArrayList<>(0);
try
{
for (com.zimbra.cs.mailbox.Folder folder : mMbox
- .getFolderList(zContext.getOperationContext(), SortBy.NONE)) {
+ .getFolderList(zContext.getOperationContext(), SortBy.NONE)) {
folderList.add(new Folder(folder));
}
}
- catch (com.zimbra.common.service.ServiceException e)
+ catch (ServiceException e)
{
throw ExceptionWrapper.wrap(e);
}
@@ -716,73 +574,16 @@ public List getFolderList(@Nonnull OperationContext zContext)
return folderList;
}
- @Nonnull
- public Item getItemByPath(@Nonnull OperationContext zContext, String path)
- throws NoSuchItemException
- {
- MailItem mailItem;
- try
- {
- mailItem = mMbox.getItemByPath(zContext.getOperationContext(), path);
- }
- catch (com.zimbra.common.service.ServiceException e)
- {
- throw ExceptionWrapper.wrap(e);
- }
-
- return new Folder(mailItem);
- }
-
- @Nonnull
- public List getModifiedFolders(int sequence)
- throws NoSuchFolderException
- {
- List folderList;
- try
- {
- folderList = mMbox.getModifiedFolders(sequence);
- }
- catch (com.zimbra.common.service.ServiceException e)
- {
- throw ExceptionWrapper.wrap(e);
- }
-
- List newFolderList = new ArrayList(folderList.size());
-
- for (com.zimbra.cs.mailbox.Folder folder : folderList)
- {
- newFolderList.add(new Folder(folder));
- }
-
- return newFolderList;
- }
- /*
- public Folder getFolderById( int id )
- throws ServiceException
- {
- MailItem folder;
- try
- {
- folder = mMbox.getFolderById(id);
- }
- catch(com.zimbra.common.service.ServiceException e)
- {
- throw ExceptionWrapper.wrap(e);
- }
- return new Folder(folder);
- }
- */
-
@Nonnull
public Folder getFolderById(@Nonnull OperationContext zContext, int id)
- throws NoSuchFolderException
+ throws NoSuchFolderException
{
MailItem folder;
try
{
folder = mMbox.getFolderById(zContext.getOperationContext(), id);
}
- catch (com.zimbra.common.service.ServiceException e)
+ catch (ServiceException e)
{
throw ExceptionWrapper.wrap(e);
}
@@ -798,7 +599,7 @@ public Mountpoint getMountpointById(@Nonnull OperationContext octxt, int id)
{
mountpoint = mMbox.getMountpointById(octxt.getOperationContext(), id);
}
- catch (com.zimbra.common.service.ServiceException e)
+ catch (ServiceException e)
{
throw ExceptionWrapper.wrap(e);
}
@@ -808,13 +609,13 @@ public Mountpoint getMountpointById(@Nonnull OperationContext octxt, int id)
@Nonnull
public CalendarItem getCalendarItemById(@Nonnull OperationContext octxt, int id)
- throws NoSuchCalendarException
+ throws NoSuchCalendarException
{
try
{
return new CalendarItem(mMbox.getCalendarItemById(octxt.getOperationContext(), id));
}
- catch (com.zimbra.common.service.ServiceException e)
+ catch (ServiceException e)
{
throw ExceptionWrapper.wrap(e);
}
@@ -822,14 +623,14 @@ public CalendarItem getCalendarItemById(@Nonnull OperationContext octxt, int id)
@Nonnull
public CalendarItem getCalendarItemByUid(@Nonnull OperationContext octxt, String uid)
- throws NoSuchCalendarException
+ throws NoSuchCalendarException
{
MailItem mailItem;
try
{
mailItem = mMbox.getCalendarItemByUid(octxt.getOperationContext(), uid);
}
- catch (com.zimbra.common.service.ServiceException e)
+ catch (ServiceException e)
{
throw ExceptionWrapper.wrap(e);
}
@@ -842,32 +643,32 @@ public CalendarItem getCalendarItemByUid(@Nonnull OperationContext octxt, String
return new CalendarItem(mailItem);
}
- @Nonnull
- public FreeBusy getFreeBusy(@Nonnull OperationContext octxt, long start, long end)
- throws NoSuchItemException
+ @Nonnull
+ public FreeBusy getFreeBusy(@Nonnull OperationContext octxt, long start, long end)
+ throws NoSuchItemException
+ {
+ com.zimbra.cs.fb.FreeBusy freeBusy;
+ try
{
- com.zimbra.cs.fb.FreeBusy freeBusy;
- try
- {
- freeBusy = mMbox.getFreeBusy(octxt.getOperationContext(),start,end,FreeBusyQuery.CALENDAR_FOLDER_ALL);
- }
- catch (com.zimbra.common.service.ServiceException e)
- {
- throw ExceptionWrapper.wrap(e);
- }
-
- if (freeBusy == null)
- {
- throw new NoSuchFreeBusyException(start, end);
- }
+ freeBusy = mMbox.getFreeBusy(octxt.getOperationContext(),start,end,FreeBusyQuery.CALENDAR_FOLDER_ALL);
+ }
+ catch (ServiceException e)
+ {
+ throw ExceptionWrapper.wrap(e);
+ }
- return new FreeBusy(freeBusy);
+ if (freeBusy == null)
+ {
+ throw new NoSuchFreeBusyException(start, end);
}
+ return new FreeBusy(freeBusy);
+ }
+
public void copyCalendarReplyInfo(
- @Nonnull CalendarItem fromCalendarItem,
- CalendarItem toCalendarItem,
- @Nonnull OperationContext zContext
+ @Nonnull CalendarItem fromCalendarItem,
+ CalendarItem toCalendarItem,
+ @Nonnull OperationContext zContext
)
{
synchronized (mMbox)
@@ -885,78 +686,70 @@ public void copyCalendarReplyInfo(
}
public void rename(@Nonnull OperationContext zContext, int id, byte type, String name, int folderId)
- throws ZimbraException
+ throws ZimbraException
{
try
{
mMbox.rename(zContext.getOperationContext(), id, Item.convertType(type), name, folderId);
}
- catch (com.zimbra.common.service.ServiceException e)
+ catch (ServiceException e)
{
throw ExceptionWrapper.wrap(e);
}
}
- public void renameMailbox(OperationContext operationContext, String oldName, String newName) {
- try {
- mMbox.renameMailbox(operationContext.getOperationContext(), oldName, newName);
- } catch (com.zimbra.common.service.ServiceException e) {
- throw ExceptionWrapper.wrap(e);
- }
- }
-
public void delete(@Nonnull OperationContext octxt, int itemId, byte type)
- throws ZimbraException
+ throws ZimbraException
{
try
{
mMbox.delete(octxt.getOperationContext(), itemId, Item.convertType(type));
}
- catch (com.zimbra.common.service.ServiceException e)
+ catch (ServiceException e)
{
throw ExceptionWrapper.wrap(e);
}
}
public void delete(@Nonnull OperationContext octxt, int[] itemIds, byte type)
- throws ZimbraException
+ throws ZimbraException
{
try
{
mMbox.delete(octxt.getOperationContext(), itemIds, Item.convertType(type), null);
}
- catch (com.zimbra.common.service.ServiceException e)
+ catch (ServiceException e)
{
throw ExceptionWrapper.wrap(e);
}
}
public void setPermissions(@Nonnull OperationContext zContext, int folderId, @Nonnull Acl acl)
- throws ZimbraException
+ throws ZimbraException
{
try
{
mMbox.setPermissions(zContext.getOperationContext(), folderId, acl.toZimbra(ACL.class));
}
- catch (com.zimbra.common.service.ServiceException e)
+ catch (ServiceException e)
{
throw ExceptionWrapper.wrap(e);
}
}
public void setColor(@Nonnull OperationContext octxt, int[] itemIds, byte type, @Nonnull Item.Color color)
- throws ZimbraException
+ throws ZimbraException
{
try
{
mMbox.setColor(
- octxt.getOperationContext(),
- itemIds,
- Item.convertType(type),
- color.toZimbra(com.zimbra.common.mailbox.Color.class)
+ octxt.getOperationContext(),
+ itemIds,
+ Item.convertType(type),
+ color.toZimbra(com.zimbra.common.mailbox.Color.class)
);
}
- catch (com.zimbra.common.service.ServiceException e)
+ catch (ServiceException e)
{
throw ExceptionWrapper.wrap(e);
}
@@ -964,12 +757,12 @@ public void setColor(@Nonnull OperationContext octxt, int[] itemIds, byte type,
@Nonnull
public CalendarItem setCalendarItem(
- @Nonnull OperationContext octxt, int folderId, int flags, String tags[],
- @Nonnull CalendarItemData defaultInv,
- @Nonnull List exceptions,
- List replies, long nextAlarm
+ @Nonnull OperationContext octxt, int folderId, int flags, String tags[],
+ @Nonnull CalendarItemData defaultInv,
+ @Nonnull List exceptions,
+ List replies, long nextAlarm
)
- throws ZimbraException
+ throws ZimbraException
{
com.zimbra.cs.mailbox.Mailbox.SetCalendarItemData[] zimbraExceptions = null;
if( exceptions.size() > 0 )
@@ -990,8 +783,8 @@ public CalendarItem setCalendarItem(
calendarItemData.invite.setMethod("PUBLISH");
com.zimbra.cs.mailbox.CalendarItem calendarItem = calendarItemData.invite.getCalendarItem();
String cid = String.format("Message Id: %s from account id %s",
- calendarItem.getId(),
- calendarItem.getAccount().getId()
+ calendarItem.getId(),
+ calendarItem.getAccount().getId()
);
ZimbraLog.extensions.warn(String.format("Setting metadata method to 'PUBLISH', '%s' is not supported for calendar item %s", oldMethod, cid));
}
@@ -1003,20 +796,20 @@ public CalendarItem setCalendarItem(
}
CalendarItem result = new CalendarItem(
- mMbox.setCalendarItem(
- octxt.getOperationContext(),
- folderId,
- flags,
- tags,
- calendarItemData,
- zimbraExceptions,
- newReplies,
- nextAlarm
- )
+ mMbox.setCalendarItem(
+ octxt.getOperationContext(),
+ folderId,
+ flags,
+ tags,
+ calendarItemData,
+ zimbraExceptions,
+ newReplies,
+ nextAlarm
+ )
);
return result;
}
- catch (com.zimbra.common.service.ServiceException e)
+ catch (ServiceException e)
{
throw ExceptionWrapper.wrap(e);
}
@@ -1025,7 +818,7 @@ public CalendarItem setCalendarItem(
public
@Nullable
Metadata getConfig(@Nonnull OperationContext octxt, String section)
- throws ZimbraException
+ throws ZimbraException
{
try
{
@@ -1036,73 +829,43 @@ Metadata getConfig(@Nonnull OperationContext octxt, String section)
}
return new Metadata(metadata);
}
- catch (com.zimbra.common.service.ServiceException e)
+ catch (ServiceException e)
{
throw ExceptionWrapper.wrap(e);
}
}
public void setConfig(@Nonnull OperationContext octxt, String section, @Nonnull Metadata config)
- throws ZimbraException
- {
- try
- {
- mMbox.setConfig(
- octxt.getOperationContext(),
- section,
- config.toZimbra(com.zimbra.cs.mailbox.Metadata.class));
- }
- catch (com.zimbra.common.service.ServiceException e)
- {
- throw ExceptionWrapper.wrap(e);
- }
- }
-
- public void removeConfig(@Nonnull OperationContext octxt, String section)
- throws ZimbraException
+ throws ZimbraException
{
try
{
mMbox.setConfig(
- octxt.getOperationContext(),
- section,
- null
- );
+ octxt.getOperationContext(),
+ section,
+ config.toZimbra(com.zimbra.cs.mailbox.Metadata.class));
}
- catch (com.zimbra.common.service.ServiceException e)
+ catch (ServiceException e)
{
throw ExceptionWrapper.wrap(e);
}
}
public void alterTag(@Nonnull OperationContext octxt, int itemId, byte type, int tagId, boolean addTag)
- throws ZimbraException
+ throws ZimbraException
{
try
{
mMbox.alterTag(octxt.getOperationContext(), itemId, Item.convertType(type), Flag.of(tagId), addTag, null);
}
- catch (com.zimbra.common.service.ServiceException e)
- {
- throw ExceptionWrapper.wrap(e);
- }
- }
-
- public void alterTag(@Nonnull OperationContext octxt, int itemId, byte type, String tagName, boolean addTag)
- throws ZimbraException
- {
- try
- {
- mMbox.alterTag(octxt.getOperationContext(), itemId, Item.convertType(type), tagName, addTag, null);
- }
- catch (com.zimbra.common.service.ServiceException e)
+ catch (ServiceException e)
{
throw ExceptionWrapper.wrap(e);
}
}
public void setTags(@Nonnull OperationContext octxt, int itemId, byte type, @Nullable Collection tags)
- throws ZimbraException
+ throws ZimbraException
{
String[] tagsArray;
if (tags == null)
@@ -1119,47 +882,47 @@ public void setTags(@Nonnull OperationContext octxt, int itemId, byte type, @Nul
{
item = mMbox.getItemById(octxt.getOperationContext(), itemId, Item.convertType(Item.TYPE_UNKNOWN));
mMbox.setTags(
- octxt.getOperationContext(),
- itemId,
- Item.convertType(type),
- item.getFlagBitmask(),
- tagsArray
+ octxt.getOperationContext(),
+ itemId,
+ Item.convertType(type),
+ item.getFlagBitmask(),
+ tagsArray
);
}
- catch (com.zimbra.common.service.ServiceException e)
+ catch (ServiceException e)
{
throw ExceptionWrapper.wrap(e);
}
}
public void setFlags(@Nonnull OperationContext octxt, int itemId, byte type, int flags)
- throws ZimbraException
+ throws ZimbraException
{
try
{
MailItem item = mMbox.getItemById(octxt.getOperationContext(), itemId, Item.convertType(Item.TYPE_UNKNOWN));
mMbox.setTags(octxt.getOperationContext(), itemId, Item.convertType(type), flags,
- item.getTags()
+ item.getTags()
);
}
- catch (com.zimbra.common.service.ServiceException e)
+ catch (ServiceException e)
{
throw ExceptionWrapper.wrap(e);
}
}
public void modifyContact(@Nonnull OperationContext octxt, int contactId, @Nonnull ParsedContact pc)
- throws ZimbraException
+ throws ZimbraException
{
try
{
mMbox.modifyContact(
- octxt.getOperationContext(),
- contactId,
- pc.toZimbra(com.zimbra.cs.mime.ParsedContact.class)
+ octxt.getOperationContext(),
+ contactId,
+ pc.toZimbra(com.zimbra.cs.mime.ParsedContact.class)
);
}
- catch (com.zimbra.common.service.ServiceException e)
+ catch (ServiceException e)
{
throw ExceptionWrapper.wrap(e);
}
@@ -1167,12 +930,12 @@ public void modifyContact(@Nonnull OperationContext octxt, int contactId, @Nonnu
@Nullable
public ZimbraItemId sendMimeMessage(
- @Nonnull OperationContext octxt, Boolean saveToSent, MimeMessage mm,
- List uploads,
- @Nullable ZimbraItemId origMsgId, String replyType,
- boolean replyToSender
+ @Nonnull OperationContext octxt, Boolean saveToSent, MimeMessage mm,
+ List uploads,
+ @Nullable ZimbraItemId origMsgId, String replyType,
+ boolean replyToSender
)
- throws ZimbraException
+ throws ZimbraException
{
ItemId itemId = null;
@@ -1186,9 +949,9 @@ public ZimbraItemId sendMimeMessage(
try
{
newItemId = mMbox.getMailSender().sendMimeMessage(
- octxt.getOperationContext(), mMbox, saveToSent, mm,
- uploads, itemId, replyType,
- null, replyToSender
+ octxt.getOperationContext(), mMbox, saveToSent, mm,
+ uploads, itemId, replyType,
+ null, replyToSender
);
if( newItemId == null ) {
@@ -1196,20 +959,20 @@ public ZimbraItemId sendMimeMessage(
}
return new ZimbraItemId(newItemId.getAccountId(), newItemId.getId());
}
- catch (com.zimbra.common.service.ServiceException e)
+ catch (ServiceException e)
{
throw ExceptionWrapper.wrap(e);
}
}
public boolean attachmentsIndexingEnabled()
- throws ZimbraException
+ throws ZimbraException
{
try
{
return mMbox.attachmentsIndexingEnabled();
}
- catch (com.zimbra.common.service.ServiceException e)
+ catch (ServiceException e)
{
throw ExceptionWrapper.wrap(e);
}
@@ -1226,71 +989,28 @@ public void move(@Nonnull OperationContext octxt, int itemId, byte type, int tar
}
mMbox.move(octxt.getOperationContext(), itemId, Item.convertType(type), targetId);
}
- catch (com.zimbra.common.service.ServiceException e)
+ catch (ServiceException e)
{
throw ExceptionWrapper.wrap(e);
}
}
- public void move(@Nonnull OperationContext octxt, int[] itemIds, byte type, int targetId) throws ZimbraException
+ public int move(@Nonnull Account dstAccount,@Nonnull OperationContext octxt, int itemId, byte type, int targetId)
+ throws ZimbraException
{
try
{
- mMbox.move(octxt.getOperationContext(), itemIds, Item.convertType(type), targetId, null);
- }
- catch (com.zimbra.common.service.ServiceException e)
- {
- throw ExceptionWrapper.wrap(e);
- }
- }
-
- public List
- copy(@Nonnull OperationContext octxt, int[] itemIds, byte type, int targetId) throws ZimbraException
- {
- try
- {
- List copiedItems = mMbox.copy(octxt.getOperationContext(), itemIds, Item.convertType(type), targetId);
- List
- result = new ArrayList<>(copiedItems.size());
- for( MailItem mailItem : copiedItems ) {
- result.add(new Item(mailItem));
- }
- return result;
- }
- catch (com.zimbra.common.service.ServiceException e)
- {
- throw ExceptionWrapper.wrap(e);
- }
- }
-
- public void createFolderPath(@Nonnull OperationContext octxt, String path) throws ZimbraException
- {
- try
- {
- mMbox.createFolderForMsgs(octxt.getOperationContext(), path);
- }
- catch (com.zimbra.common.service.ServiceException e)
- {
- throw ExceptionWrapper.wrap(e);
- }
- }
-
-
-
- public int move(@Nonnull Account dstAccount,@Nonnull OperationContext octxt, int itemId, byte type, int targetId)
- throws ZimbraException
- {
- try
- {
- com.zimbra.cs.service.util.ItemId zimbraItemId = new com.zimbra.cs.service.util.ItemId(
+ ItemId zimbraItemId = new ItemId(
dstAccount.getId(),
targetId
);
ItemActionHelper op = ItemActionHelper.MOVE(octxt.getOperationContext(),
- mMbox,
- SoapProtocol.Soap12,
- Arrays.asList(itemId),
- Item.convertType(type),
- null,
- zimbraItemId);
+ mMbox,
+ SoapProtocol.Soap12,
+ Arrays.asList(itemId),
+ Item.convertType(type),
+ null,
+ zimbraItemId);
List createdIds;
createdIds = op.getResult().getSuccessIds();
if (createdIds == null)
@@ -1301,80 +1021,48 @@ public int move(@Nonnull Account dstAccount,@Nonnull OperationContext octxt, int
{
throw new NoSuchItemException(Integer.toString(itemId));
}
- com.zimbra.cs.service.util.ItemId newZimbraItemId = new com.zimbra.cs.service.util.ItemId(createdIds.get(0),(String)null);
+ ItemId newZimbraItemId = new ItemId(createdIds.get(0),(String)null);
return newZimbraItemId.getId();
}
- catch (com.zimbra.common.service.ServiceException e)
+ catch (ServiceException e)
{
throw ExceptionWrapper.wrap(e);
}
}
public List getCalendarItemsForRange(
- @Nonnull OperationContext octxt, byte type, long start,
- long end, int folderId, int[] excludeFolders
+ @Nonnull OperationContext octxt, byte type, long start,
+ long end, int folderId, int[] excludeFolders
)
- throws ZimbraException
+ throws ZimbraException
{
try
{
List zimbraCalendarItems = mMbox.getCalendarItemsForRange(
- octxt.getOperationContext(),
- Item.convertType(type),
- start,
- end,
- folderId,
- excludeFolders
+ octxt.getOperationContext(),
+ Item.convertType(type),
+ start,
+ end,
+ folderId,
+ excludeFolders
);
return ZimbraListWrapper.wrapCalendarItems(zimbraCalendarItems);
}
- catch (com.zimbra.common.service.ServiceException e)
- {
- throw ExceptionWrapper.wrap(e);
- }
- }
-
- public List getItemListByDates(
- @Nonnull OperationContext octxt, byte type, long start,
- long end, int folderId, boolean descending
- )
- throws ZimbraException
- {
- List itemIds;
-
- try
- {
- DbMailItem.QueryParams options = new DbMailItem.QueryParams();
- options.setFolderIds(Collections.singletonList(folderId));
- options.setIncludedTypes(Collections.singletonList(Item.convertType(type)));
- options.setDateAfter((int) (start / 1000L));
- options.setDateBefore((int) (end / 1000L));
- if (descending)
- {
- options.setOrderBy(Collections.singletonList("date DESC"));
- }
- else
- {
- options.setOrderBy(Collections.singletonList("date ASC"));
- }
- itemIds = mMbox.getItemIdList(octxt.getOperationContext(), options);
- return itemIds;
- }
- catch (com.zimbra.common.service.ServiceException e)
+ catch (ServiceException e)
{
throw ExceptionWrapper.wrap(e);
}
}
public List listItemIds(@Nonnull OperationContext octxt, byte type, int folderId)
- throws NoSuchItemException
+ throws NoSuchItemException
{
try
{
return mMbox.listItemIds(octxt.getOperationContext(), Item.convertType(type), folderId);
}
- catch (com.zimbra.common.service.ServiceException e)
+ catch (ServiceException e)
{
throw ExceptionWrapper.wrap(e);
}
@@ -1382,17 +1070,17 @@ public List listItemIds(@Nonnull OperationContext octxt, byte type, int
@Nonnull
public Iterator>> getItemIds(@Nonnull OperationContext octxt, int folderId)
- throws ZimbraException
+ throws ZimbraException
{
try
{
- Map> map = new HashMap>();
- Iterator>> iterator
- = mMbox.getItemIds(octxt.getOperationContext(), folderId).iterator();
+ Map> map = new HashMap<>();
+ Iterator>> iterator
+ = mMbox.getItemIds(octxt.getOperationContext(), folderId).iterator();
while (iterator.hasNext())
{
- Map.Entry> entry = iterator.next();
- List list = new ArrayList();
+ Map.Entry> entry = iterator.next();
+ List list = new ArrayList<>();
for (TypedIdList.ItemInfo item : entry.getValue())
{
list.add(item.getId());
@@ -1401,7 +1089,7 @@ public Iterator>> getItemIds(@Nonnull OperationCon
}
return map.entrySet().iterator();
}
- catch (com.zimbra.common.service.ServiceException e)
+ catch (ServiceException e)
{
throw ExceptionWrapper.wrap(e);
}
@@ -1413,7 +1101,7 @@ public boolean canRead(OperationContext octxt, int itemId)
try
{
- rights = mMbox.getEffectivePermissions(octxt.getOperationContext(), itemId, com.zimbra.cs.mailbox.MailItem.Type.UNKNOWN);
+ rights = mMbox.getEffectivePermissions(octxt.getOperationContext(), itemId, Type.UNKNOWN);
}
catch (ServiceException e)
{
@@ -1429,7 +1117,7 @@ public boolean canWrite(OperationContext octxt, int itemId)
try
{
- rights = mMbox.getEffectivePermissions(octxt.getOperationContext(), itemId, com.zimbra.cs.mailbox.MailItem.Type.UNKNOWN);
+ rights = mMbox.getEffectivePermissions(octxt.getOperationContext(), itemId, Type.UNKNOWN);
}
catch (ServiceException e)
{
@@ -1440,11 +1128,11 @@ public boolean canWrite(OperationContext octxt, int itemId)
}
public void modifyPartStat(
- @Nonnull OperationContext octxt, int calItemId,
- @Nullable RecurrenceId recurId, String cnStr,
- String addressStr, String cutypeStr,
- String roleStr, String partStatStr,
- Boolean rsvp, int seqNo, long dtStamp
+ @Nonnull OperationContext octxt, int calItemId,
+ @Nullable RecurrenceId recurId, String cnStr,
+ String addressStr, String cutypeStr,
+ String roleStr, String partStatStr,
+ Boolean rsvp, int seqNo, long dtStamp
)
throws ZimbraException
{
@@ -1469,7 +1157,7 @@ public void modifyPartStat(
seqNo,
dtStamp);
}
- catch (com.zimbra.common.service.ServiceException e)
+ catch (ServiceException e)
{
throw ExceptionWrapper.wrap(e);
}
@@ -1477,14 +1165,14 @@ public void modifyPartStat(
@Nonnull
public Tag getTagById(@Nonnull OperationContext octxt, int itemId)
- throws NoSuchItemException
+ throws NoSuchItemException
{
MailItem tag;
try
{
tag = mMbox.getTagById(octxt.getOperationContext(), itemId);
}
- catch (com.zimbra.common.service.ServiceException e)
+ catch (ServiceException e)
{
throw ExceptionWrapper.wrap(e);
}
@@ -1493,7 +1181,7 @@ public Tag getTagById(@Nonnull OperationContext octxt, int itemId)
@Nullable
public Tag getTagByName(@Nonnull OperationContext octxt, String name)
- throws NoSuchItemException
+ throws NoSuchItemException
{
try
{
@@ -1504,58 +1192,52 @@ public Tag getTagByName(@Nonnull OperationContext octxt, String name)
}
return new Tag(tagByName);
}
- catch (com.zimbra.common.service.ServiceException e)
+ catch (ServiceException e)
{
throw ExceptionWrapper.wrap(e);
}
}
public void setCustomData(@Nonnull OperationContext octxt, int itemId, byte type, @Nonnull Item.CustomMetadata custom)
- throws ZimbraException
+ throws ZimbraException
{
try
{
mMbox.setCustomData(
- octxt.getOperationContext(),
- itemId,
- Item.convertType(type),
- custom.toZimbra(MailItem.CustomMetadata.class)
+ octxt.getOperationContext(),
+ itemId,
+ Item.convertType(type),
+ custom.toZimbra(MailItem.CustomMetadata.class)
);
}
- catch (com.zimbra.common.service.ServiceException e)
+ catch (ServiceException e)
{
throw ExceptionWrapper.wrap(e);
}
}
- @Nonnull
- public ZimbraItemId nextItemId()
- {
- return new ZimbraItemId(mMbox.getAccountId(), 0);
- }
-
@Nonnull
public OperationContext newOperationContext()
- throws ZimbraException
+ throws ZimbraException
{
try
{
return new OperationContext(new com.zimbra.cs.mailbox.OperationContext(mMbox));
}
- catch (com.zimbra.common.service.ServiceException e)
+ catch (ServiceException e)
{
throw ExceptionWrapper.wrap(e);
}
}
public void beginTrackingSync()
- throws ZimbraException
+ throws ZimbraException
{
try
{
mMbox.beginTrackingSync();
}
- catch (com.zimbra.common.service.ServiceException e)
+ catch (ServiceException e)
{
throw ExceptionWrapper.wrap(e);
}
@@ -1566,11 +1248,6 @@ public int getLastChangeID()
return mMbox.getLastChangeID();
}
- public int getLastItemId()
- {
- return mMbox.getLastItemId();
- }
-
public void clearItemCache() throws ZimbraException
{
mMbox.purge(Item.convertType(Item.TYPE_UNKNOWN));
@@ -1583,32 +1260,32 @@ public void purgeCache()
public void clearCache(byte type) throws ZimbraException
{
- mMbox.purge(Item.convertType(type));
+ mMbox.purge(Item.convertType(type));
}
@Nonnull
public QueryResults search(
- @Nonnull OperationContext octxt,
- String queryString,
- @Nonnull byte[] types,
- @Nonnull SortedBy sortBy,
- int chunkSize
+ @Nonnull OperationContext octxt,
+ String queryString,
+ @Nonnull byte[] types,
+ @Nonnull SortedBy sortBy,
+ int chunkSize
)
- throws ZimbraException
+ throws ZimbraException
{
return search(octxt, queryString, types, sortBy, chunkSize, 0, false, false);
}
@Nonnull
public QueryResults search(
- @Nonnull OperationContext octxt,
- String queryString,
- @Nonnull byte[] types,
- @Nonnull SortedBy sortBy,
- int chunkSize,
- int offset,
- boolean onlyIds
+ @Nonnull OperationContext octxt,
+ String queryString,
+ @Nonnull byte[] types,
+ @Nonnull SortedBy sortBy,
+ int chunkSize,
+ int offset,
+ boolean onlyIds
)
throws ZimbraException
{
@@ -1616,41 +1293,41 @@ public QueryResults search(
}
public QueryResults search(
- OperationContext operationContext,
- org.openzal.zal.SearchParams searchParams
+ OperationContext operationContext,
+ org.openzal.zal.SearchParams searchParams
) {
ZimbraQueryResults result;
try {
result = mMbox.index.search(
- SoapProtocol.Soap12,
- operationContext.getOperationContext(),
- searchParams.toZimbra(SearchParams.class)
+ SoapProtocol.Soap12,
+ operationContext.getOperationContext(),
+ searchParams.toZimbra(SearchParams.class)
);
} catch (ServiceException e) {
throw ExceptionWrapper.wrap(e);
}
return new QueryResults(
- result
+ result
);
}
@Nonnull
public QueryResults search(
- @Nonnull OperationContext octxt,
- String queryString,
- @Nonnull byte[] types,
- @Nonnull SortedBy sortBy,
- int chunkSize,
- int offset,
- boolean onlyIds,
- boolean inDumpster
+ @Nonnull OperationContext octxt,
+ String queryString,
+ @Nonnull byte[] types,
+ @Nonnull SortedBy sortBy,
+ int chunkSize,
+ int offset,
+ boolean onlyIds,
+ boolean inDumpster
)
- throws ZimbraException
+ throws ZimbraException
{
try
{
- Set typeList = new HashSet(types.length);
+ Set typeList = new HashSet(types.length);
for (byte type : types)
{
typeList.add(Item.convertType(type));
@@ -1658,7 +1335,7 @@ public QueryResults search(
SearchParams.Fetch fetchMode = onlyIds ? SearchParams.Fetch.IDS : SearchParams.Fetch.NORMAL;
- com.zimbra.cs.index.SearchParams params = new com.zimbra.cs.index.SearchParams();
+ SearchParams params = new SearchParams();
params.setQueryString(queryString);
params.setTimeZone(null);
params.setLocale(null);
@@ -1671,16 +1348,16 @@ public QueryResults search(
params.setOffset(offset);
ZimbraQueryResults result = mMbox.index.search(
- SoapProtocol.Soap12,
- octxt.getOperationContext(),
- params
+ SoapProtocol.Soap12,
+ octxt.getOperationContext(),
+ params
);
if( offset >= 1 )
result.skipToHit(offset-1);
return new QueryResults(
- result
+ result
);
}
catch (Exception e)
@@ -1691,9 +1368,9 @@ public QueryResults search(
@Nonnull
public List
- getItemList(byte type, @Nonnull OperationContext zContext)
- throws ZimbraException
+ throws ZimbraException
{
- List
- result = new LinkedList
- ();
+ List
- result = new LinkedList<>();
beginTransaction("ZxGetItemList", zContext.getOperationContext());
try
@@ -1767,27 +1444,27 @@ else if (type == Item.TYPE_FLAG)
@Nonnull
public Folder createFolder(
- @Nonnull OperationContext octxt, String name, int parentId,
- byte attrs, byte defaultView, int flags,
- @Nonnull Item.Color color, String url
+ @Nonnull OperationContext octxt, String name, int parentId,
+ byte attrs, byte defaultView, int flags,
+ @Nonnull Item.Color color, String url
)
- throws ZimbraException
+ throws ZimbraException
{
MailItem folder;
try
{
folder = mMbox.createFolder(
- octxt.getOperationContext(),
- name,
- parentId,
- attrs,
- Item.convertType(defaultView),
- flags,
- color.toZimbra(com.zimbra.common.mailbox.Color.class),
- url
+ octxt.getOperationContext(),
+ name,
+ parentId,
+ attrs,
+ Item.convertType(defaultView),
+ flags,
+ color.toZimbra(com.zimbra.common.mailbox.Color.class),
+ url
);
}
- catch (com.zimbra.common.service.ServiceException e)
+ catch (ServiceException e)
{
throw ExceptionWrapper.wrap(e);
}
@@ -1797,27 +1474,27 @@ public Folder createFolder(
@Nonnull
public Folder createFolder(
- OperationContext operationContext,
- String path
+ OperationContext operationContext,
+ String path
) {
MailItem folder;
try {
FolderOptions fopts = new FolderOptions();
folder = mMbox.createFolder(operationContext.getOperationContext(), path, fopts);
- } catch (com.zimbra.common.service.ServiceException e) {
+ } catch (ServiceException e) {
throw ExceptionWrapper.wrap(e);
}
return new Folder(folder);
}
public void setFolderRetentionPolicy(@Nonnull OperationContext octxt, int folderId, RetentionPolicy retentionPolicy)
- throws ZimbraException {
+ throws ZimbraException {
try {
mMbox.setRetentionPolicy(
- octxt.getOperationContext(),
- folderId,
- Type.FOLDER,
- retentionPolicy.toZimbra(com.zimbra.soap.mail.type.RetentionPolicy.class)
+ octxt.getOperationContext(),
+ folderId,
+ Type.FOLDER,
+ retentionPolicy.toZimbra(com.zimbra.soap.mail.type.RetentionPolicy.class)
);
} catch (ServiceException e) {
throw ExceptionWrapper.wrap(e);
@@ -1826,27 +1503,27 @@ public void setFolderRetentionPolicy(@Nonnull OperationContext octxt, int folder
@Nonnull
public SearchFolder createSearchFolder(
- @Nonnull OperationContext octxt, int folderId, String name,
- String query, String types, String sort,
- int flags, @Nonnull Item.Color color
+ @Nonnull OperationContext octxt, int folderId, String name,
+ String query, String types, String sort,
+ int flags, @Nonnull Item.Color color
)
- throws ZimbraException
+ throws ZimbraException
{
MailItem item;
try
{
item = mMbox.createSearchFolder(
- octxt.getOperationContext(),
- folderId,
- name,
- query,
- types,
- sort,
- flags,
- color.toZimbra(com.zimbra.common.mailbox.Color.class)
+ octxt.getOperationContext(),
+ folderId,
+ name,
+ query,
+ types,
+ sort,
+ flags,
+ color.toZimbra(com.zimbra.common.mailbox.Color.class)
);
}
- catch (com.zimbra.common.service.ServiceException e)
+ catch (ServiceException e)
{
throw ExceptionWrapper.wrap(e);
}
@@ -1854,47 +1531,20 @@ public SearchFolder createSearchFolder(
return new SearchFolder(item);
}
- @Nonnull
- public SearchFolder getSearchFolderById(@Nonnull OperationContext zContext, int id) throws NoSuchFolderException {
- MailItem folder;
-
- try
- {
- folder = mMbox.getSearchFolderById(zContext.getOperationContext(), id);
- }
- catch (com.zimbra.common.service.ServiceException e)
- {
- throw ExceptionWrapper.wrap(e);
- }
-
- return new SearchFolder(folder);
- }
-
- public void modifySearchFolder(OperationContext zContext, int id, String query, String types, String sort) {
- try
- {
- mMbox.modifySearchFolder(zContext.getOperationContext(), id, query, types, sort);
- }
- catch (com.zimbra.common.service.ServiceException e)
- {
- throw ExceptionWrapper.wrap(e);
- }
- }
-
@Nonnull
public Tag createTag(@Nonnull OperationContext octxt, String name, @Nonnull Item.Color color)
- throws ZimbraException
+ throws ZimbraException
{
MailItem tag;
try
{
tag = mMbox.createTag(
- octxt.getOperationContext(),
- name,
- color.toZimbra(com.zimbra.common.mailbox.Color.class)
+ octxt.getOperationContext(),
+ name,
+ color.toZimbra(com.zimbra.common.mailbox.Color.class)
);
}
- catch (com.zimbra.common.service.ServiceException e)
+ catch (ServiceException e)
{
throw ExceptionWrapper.wrap(e);
}
@@ -1904,12 +1554,12 @@ public Tag createTag(@Nonnull OperationContext octxt, String name, @Nonnull Item
@Nonnull
public Message addMessage(
- @Nonnull OperationContext octxt, InputStream in, int sizeHint, Long receivedDate,
- int folderId, boolean noIcal,
- int flags, Collection tags, int conversationId, String rcptEmail,
- @Nullable Item.CustomMetadata customData
+ @Nonnull OperationContext octxt, InputStream in, int sizeHint, Long receivedDate,
+ int folderId, boolean noIcal,
+ int flags, Collection tags, int conversationId, String rcptEmail,
+ @Nullable Item.CustomMetadata customData
)
- throws IOException, ZimbraException
+ throws IOException, ZimbraException
{
DeliveryOptions opts = new DeliveryOptions();
opts.setFolderId(folderId);
@@ -1927,14 +1577,14 @@ public Message addMessage(
try
{
message = mMbox.addMessage(octxt.getOperationContext(),
- in,
- sizeHint,
- receivedDate,
- opts,
- null
+ in,
+ sizeHint,
+ receivedDate,
+ opts,
+ null
);
}
- catch (com.zimbra.common.service.ServiceException e)
+ catch (ServiceException e)
{
throw ExceptionWrapper.wrap(e);
}
@@ -1944,11 +1594,11 @@ public Message addMessage(
@Nonnull
public Message simpleAddMessage(
- @Nonnull OperationContext octxt,
- InputStream in,
- int folderId
+ @Nonnull OperationContext octxt,
+ InputStream in,
+ int folderId
)
- throws IOException, ZimbraException
+ throws IOException, ZimbraException
{
MailItem message;
try
@@ -1957,15 +1607,15 @@ public Message simpleAddMessage(
opts.setFolderId(folderId);
opts.setDraftInfo(null);
message = mMbox.addMessage(
- octxt.getOperationContext(),
- in,
- 0L,
- null,
- opts,
- null
+ octxt.getOperationContext(),
+ in,
+ 0L,
+ null,
+ opts,
+ null
);
}
- catch (com.zimbra.common.service.ServiceException e)
+ catch (ServiceException e)
{
throw ExceptionWrapper.wrap(e);
}
@@ -1975,13 +1625,13 @@ public Message simpleAddMessage(
@Nonnull
public Message saveDraft(@Nonnull OperationContext octxt,@Nonnull ParsedMessage parsedMessage, int id)
- throws IOException, ZimbraException
+ throws IOException, ZimbraException
{
try
{
return new Message(mMbox.saveDraft(octxt.getOperationContext(), parsedMessage.toZimbra(com.zimbra.cs.mime.ParsedMessage.class), id));
}
- catch( com.zimbra.common.service.ServiceException e )
+ catch( ServiceException e )
{
throw ExceptionWrapper.wrap(e);
}
@@ -2012,7 +1662,7 @@ public List getContacts(OperationContext octxt, int folderId)
contacts.add(new Contact(contact));
}
}
- catch (com.zimbra.common.service.ServiceException e)
+ catch (ServiceException e)
{
throw ExceptionWrapper.wrap(e);
}
@@ -2023,24 +1673,24 @@ public List getContacts(OperationContext octxt, int folderId)
@Nonnull
public Contact createContact(OperationContext octxt, ParsedContact pc, int folderId)
{
- return createContact(octxt, pc, folderId, Collections.emptyList());
+ return createContact(octxt, pc, folderId, Collections.emptyList());
}
@Nonnull
public Contact createContact(@Nonnull OperationContext octxt, @Nonnull ParsedContact pc, int folderId, @Nonnull Collection tags)
- throws ZimbraException
+ throws ZimbraException
{
MailItem contact;
try
{
contact = mMbox.createContact(
- octxt.getOperationContext(),
- pc.toZimbra(com.zimbra.cs.mime.ParsedContact.class),
- folderId,
- tags.toArray(new String[tags.size()])
+ octxt.getOperationContext(),
+ pc.toZimbra(com.zimbra.cs.mime.ParsedContact.class),
+ folderId,
+ tags.toArray(new String[tags.size()])
);
}
- catch (com.zimbra.common.service.ServiceException e)
+ catch (ServiceException e)
{
throw ExceptionWrapper.wrap(e);
}
@@ -2048,13 +1698,13 @@ public Contact createContact(@Nonnull OperationContext octxt, @Nonnull ParsedCon
return new Contact(contact);
}
public int addInvite(
- @Nonnull OperationContext octxt, @Nonnull Invite inv,
- int folderId, @Nullable ParsedMessage pm,
- boolean preserveExistingAlarms,
- boolean discardExistingInvites,
- boolean addRevision
+ @Nonnull OperationContext octxt, @Nonnull Invite inv,
+ int folderId, @Nullable ParsedMessage pm,
+ boolean preserveExistingAlarms,
+ boolean discardExistingInvites,
+ boolean addRevision
)
- throws ZimbraException
+ throws ZimbraException
{
try
{
@@ -2064,22 +1714,22 @@ public int addInvite(
parsedMessage = pm.toZimbra(com.zimbra.cs.mime.ParsedMessage.class);
}
return mMbox.addInvite(
- octxt.getOperationContext(),
- inv.toZimbra(com.zimbra.cs.mailbox.calendar.Invite.class),
- folderId, parsedMessage,
- preserveExistingAlarms,
- discardExistingInvites,
- addRevision
+ octxt.getOperationContext(),
+ inv.toZimbra(com.zimbra.cs.mailbox.calendar.Invite.class),
+ folderId, parsedMessage,
+ preserveExistingAlarms,
+ discardExistingInvites,
+ addRevision
).calItemId;
}
- catch (com.zimbra.common.service.ServiceException e)
+ catch (ServiceException e)
{
throw ExceptionWrapper.wrap(e);
}
}
public void addInvite(@Nonnull OperationContext octxt, @Nonnull Invite inv, int folderId)
- throws ZimbraException
+ throws ZimbraException
{
try
{
@@ -2094,7 +1744,7 @@ public void addInvite(@Nonnull OperationContext octxt, @Nonnull Invite inv, int
true
);
}
- catch (com.zimbra.common.service.ServiceException e)
+ catch (ServiceException e)
{
throw ExceptionWrapper.wrap(e);
}
@@ -2116,7 +1766,7 @@ public void addInvite(@Nonnull OperationContext octxt, @Nonnull Invite inv, int
true
);
}
- catch (com.zimbra.common.service.ServiceException e)
+ catch (ServiceException e)
{
throw ExceptionWrapper.wrap(e);
}
@@ -2124,29 +1774,29 @@ public void addInvite(@Nonnull OperationContext octxt, @Nonnull Invite inv, int
@Nonnull
public Mountpoint createMountpoint(
- @Nonnull OperationContext octxt, int folderId,
- String name, String ownerId,
- int remoteId, String remoteUuid,
- byte view, int flags,
- @Nonnull Item.Color color
+ @Nonnull OperationContext octxt, int folderId,
+ String name, String ownerId,
+ int remoteId, String remoteUuid,
+ byte view, int flags,
+ @Nonnull Item.Color color
)
- throws ZimbraException
+ throws ZimbraException
{
MailItem mountPoint;
try
{
mountPoint = mMbox.createMountpoint(
- octxt.getOperationContext(), folderId,
- name, ownerId,
- remoteId,
- remoteUuid,
- Item.convertType(view),
- flags,
- color.toZimbra(com.zimbra.common.mailbox.Color.class),
- false
+ octxt.getOperationContext(), folderId,
+ name, ownerId,
+ remoteId,
+ remoteUuid,
+ Item.convertType(view),
+ flags,
+ color.toZimbra(com.zimbra.common.mailbox.Color.class),
+ false
);
}
- catch (com.zimbra.common.service.ServiceException e)
+ catch (ServiceException e)
{
throw ExceptionWrapper.wrap(e);
}
@@ -2154,115 +1804,17 @@ public Mountpoint createMountpoint(
return new Mountpoint(mountPoint);
}
-
- @Nonnull
- public Chat createChat(
- @Nonnull OperationContext octxt,
- @Nonnull ParsedMessage pm,
- int folderId, int flags,
- @Nonnull Tags tags
- )
- throws ZimbraException, IOException
- {
- MailItem chat;
- try
- {
- chat = mMbox.createChat(
- octxt.getOperationContext(),
- pm.toZimbra(com.zimbra.cs.mime.ParsedMessage.class),
- folderId,
- flags,
- tags.getTags()
- );
- }
- catch (com.zimbra.common.service.ServiceException e)
- {
- throw ExceptionWrapper.wrap(e);
- }
-
- return new Chat(chat);
- }
-
- @Nonnull
- public Chat createChat(
- @Nonnull OperationContext octxt,
- @Nonnull ParsedMessage pm,
- int folderId, int flags
- )
- throws ZimbraException, IOException
- {
- MailItem chat;
- try
- {
- chat = mMbox.createChat(
- octxt.getOperationContext(),
- pm.toZimbra(com.zimbra.cs.mime.ParsedMessage.class),
- folderId,
- flags,
- null);
- }
- catch (com.zimbra.common.service.ServiceException e)
- {
- throw ExceptionWrapper.wrap(e);
- }
-
- return new Chat(chat);
- }
-
- @Nullable private static Method sEndTransactionMethod = null;
-
- static
- {
- try
- {
- Class partypes[] = new Class[1];
- partypes[0] = boolean.class;
-
- sEndTransactionMethod = com.zimbra.cs.mailbox.Mailbox.class.getDeclaredMethod("endTransaction", partypes);
- sEndTransactionMethod.setAccessible(true);
- }
- catch (Throwable ex)
- {
- ZimbraLog.extensions.fatal("ZAL Reflection Initialization Exception: " + Utils.exceptionToString(ex));
- throw new RuntimeException(ex);
- }
- }
-
- @Nullable private static Method sBeginTransactionMethod = null;
-
- static
- {
- try
- {
- Class partypes[] = new Class[2];
- partypes[0] = String.class;
- partypes[1] = com.zimbra.cs.mailbox.OperationContext.class;
-
- sBeginTransactionMethod = com.zimbra.cs.mailbox.Mailbox.class.getDeclaredMethod("beginTransaction", partypes);
- sBeginTransactionMethod.setAccessible(true);
- }
- catch (Throwable ex)
- {
- ZimbraLog.extensions.fatal("ZAL Reflection Initialization Exception: " + Utils.exceptionToString(ex));
- throw new RuntimeException(ex);
- }
- }
-
public void beginTransaction(String name, @Nonnull OperationContext context)
{
beginTransaction(name, context.getOperationContext());
}
- private final void beginTransaction(String name, com.zimbra.cs.mailbox.OperationContext zContext)
- throws ZimbraException
+ private void beginTransaction(String name, com.zimbra.cs.mailbox.OperationContext zContext)
+ throws ZimbraException
{
try
{
- Object parameters[] = new Object[2];
- parameters[0] = name;
- parameters[1] = zContext;
-
- sBeginTransactionMethod.invoke(mMbox, parameters);
+ mMbox.beginTransaction(name, zContext);
}
catch (Exception ex)
{
@@ -2271,14 +1823,11 @@ private final void beginTransaction(String name, com.zimbra.cs.mailbox.Operation
}
public final void endTransaction(boolean success)
- throws ZimbraException
+ throws ZimbraException
{
- Object parameters[] = new Object[1];
- parameters[0] = success;
-
try
{
- sEndTransactionMethod.invoke(mMbox, parameters);
+ mMbox.endTransaction(success);
}
catch (Exception ex)
{
@@ -2286,38 +1835,16 @@ public final void endTransaction(boolean success)
}
}
- private static Method sRawGetItem;
-
- static
- {
- try
- {
- Class partypes[] = new Class[1];
- partypes[0] = MailItem.UnderlyingData.class;
-
- sRawGetItem = com.zimbra.cs.mailbox.Mailbox.class.getDeclaredMethod("getItem", partypes);
- sRawGetItem.setAccessible(true);
- }
- catch (Throwable ex)
- {
- ZimbraLog.extensions.fatal("ZAL Reflection Initialization Exception: " + Utils.exceptionToString(ex));
- throw new RuntimeException(ex);
- }
- }
-
/*
* Warning: unsynchronized private access to mailbox
*/
@Nullable
- private final Item rawGetItem(@Nonnull Item.UnderlyingData data)
- throws InternalServerException
+ private Item rawGetItem(@Nonnull Item.UnderlyingData data)
+ throws InternalServerException
{
- Object parameters[] = new Object[1];
- parameters[0] = data.toZimbra(MailItem.UnderlyingData.class);
-
try
{
- MailItem item = (MailItem) sRawGetItem.invoke(mMbox, parameters);
+ MailItem item = mMbox.getItem(data.toZimbra(MailItem.UnderlyingData.class));
if(item != null)
{
return new Item(item);
@@ -2333,46 +1860,21 @@ private final Item rawGetItem(@Nonnull Item.UnderlyingData data)
}
}
- private static Method sGetAllFlags;
-
- static
- {
- try
- {
- Class partypes[] = new Class[1];
- partypes[0] = com.zimbra.cs.mailbox.Mailbox.class;
-
- sGetAllFlags = com.zimbra.cs.mailbox.Flag.class.getDeclaredMethod("allOf", partypes);
- sGetAllFlags.setAccessible(true);
- }
- catch (Throwable ex)
- {
- ZimbraLog.extensions.fatal("ZAL Reflection Initialization Exception: " + Utils.exceptionToString(ex));
- throw new RuntimeException(ex);
- }
- }
-
/*
* Warning: unsynchronized private access to mailbox
*/
@Nullable
- private final List getAllFlags()
- throws ZimbraException
+ private List getAllFlags()
+ throws ZimbraException
{
- Object parameters[] = new Object[1];
- parameters[0] = mMbox;
-
- try
- {
- return (List) sGetAllFlags.invoke(null, parameters);
- }
- catch (Throwable ex)
- {
+ try {
+ return com.zimbra.cs.mailbox.Flag.allOf(mMbox);
+ } catch (ServiceException | RuntimeException e) {
return null;
}
}
- public final static boolean ACLIsEmpty(@Nullable Acl acl)
+ public static boolean ACLIsEmpty(@Nullable Acl acl)
{
if (acl == null)
{
@@ -2381,109 +1883,27 @@ public final static boolean ACLIsEmpty(@Nullable Acl acl)
return acl.isEmpty();
}
- private static Field sTagCache;
-
- static
- {
- try
- {
- sTagCache = com.zimbra.cs.mailbox.Mailbox.class.getDeclaredField("mTagCache");
- sTagCache.setAccessible(true);
- }
- catch (Throwable ex)
- {
- ZimbraLog.extensions.fatal("ZAL Reflection Initialization Exception: " + Utils.exceptionToString(ex));
- throw new RuntimeException(ex);
- }
- }
-
/*
* Warning: unsynchronized private access to mailbox
*/
@Nullable
- private final Map