Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ZCS-11861 SOAP API: Need soap API to get the list of Available StoreManagers for the volume #1365

Draft
wants to merge 3 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions common/src/java/com/zimbra/common/soap/AdminConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,8 @@ public final class AdminConstants {
public static final String E_DELETE_VOLUME_RESPONSE = "DeleteVolumeResponse";
public static final String E_GET_ALL_VOLUMES_REQUEST = "GetAllVolumesRequest";
public static final String E_GET_ALL_VOLUMES_RESPONSE = "GetAllVolumesResponse";
public static final String E_GET_ALL_STORE_MANAGERS_REQUEST = "GetAllStoreManagersRequest";
public static final String E_GET_ALL_STORE_MANAGERS_RESPONSE = "GetAllStoreManagersResponse";
public static final String E_GET_CURRENT_VOLUMES_REQUEST = "GetCurrentVolumesRequest";
public static final String E_GET_CURRENT_VOLUMES_RESPONSE = "GetCurrentVolumesResponse";
public static final String E_SET_CURRENT_VOLUME_REQUEST = "SetCurrentVolumeRequest";
Expand Down Expand Up @@ -536,11 +538,11 @@ public final class AdminConstants {
// Skins
public static final String E_GET_ALL_SKINS_REQUEST = "GetAllSkinsRequest";
public static final String E_GET_ALL_SKINS_RESPONSE = "GetAllSkinsResponse";

// Sending Emails
public static final String E_SEND_MDM_NOTIFICATION_EMAIL_REQUEST = "SendMdmNotificationEmailRequest";
public static final String E_SEND_MDM_NOTIFICATION_EMAIL_RESPONSE = "SendMdmNotificationEmailResponse";

// Active Sync
public static final QName SEND_MDM_NOTIFICATION_EMAIL_REQUEST = QName.get(E_SEND_MDM_NOTIFICATION_EMAIL_REQUEST, NAMESPACE);
public static final QName SEND_MDM_NOTIFICATION_EMAIL_RESPONSE = QName.get(E_SEND_MDM_NOTIFICATION_EMAIL_RESPONSE, NAMESPACE);
Expand Down Expand Up @@ -1176,6 +1178,7 @@ public final class AdminConstants {
public static final String E_NI = "ni";
public static final String E_NUM_OF_PAGES = "numpages";
public static final String E_VOLUME = "volume";
public static final String E_STORE_MANAGER = "storeManager";
public static final String E_VOLUME_EXT = "volumeExternalInfo";
public static final String E_VOLUME_OPENIO_EXT = "volumeExternalOpenIoInfo";
public static final String E_STORE_MANAGER_RUNTIME_SWITCH_RESULT = "storeManagerRuntimeSwitchResult";
Expand Down
4 changes: 3 additions & 1 deletion soap/src/java/com/zimbra/soap/JaxbUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,8 @@ public final class JaxbUtil {
com.zimbra.soap.admin.message.GetAllServersResponse.class,
com.zimbra.soap.admin.message.GetAllSkinsRequest.class,
com.zimbra.soap.admin.message.GetAllSkinsResponse.class,
com.zimbra.soap.admin.message.GetAllStoreManagersRequest.class,
com.zimbra.soap.admin.message.GetAllStoreManagersResponse.class,
com.zimbra.soap.admin.message.GetAllUCProvidersRequest.class,
com.zimbra.soap.admin.message.GetAllUCProvidersResponse.class,
com.zimbra.soap.admin.message.GetAllUCServicesRequest.class,
Expand Down Expand Up @@ -1675,7 +1677,7 @@ public static ModifyItemNotification getModifiedItemSOAP(BaseItemInfo mod, int r
ImapMessageInfo messageInfo = new ImapMessageInfo(mod.getIdInMailbox(), mod.getImapUid(), mod.getMailItemType().toString(), mod.getFlagBitmask(), tags);
return new ModifyNotification.ModifyItemNotification(messageInfo, reason);
}

public static DeleteItemNotification getDeletedItemSOAP(int itemId, String type) throws ServiceException {
return new DeleteItemNotification(itemId, type);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* ***** BEGIN LICENSE BLOCK *****
* Zimbra Collaboration Suite Server
* Copyright (C) 2022 Synacor, Inc.
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software Foundation,
* version 2 of the License.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
* You should have received a copy of the GNU General Public License along with this program.
* If not, see <https://www.gnu.org/licenses/>.
* ***** END LICENSE BLOCK *****
*/

package com.zimbra.soap.admin.message;

import javax.xml.bind.annotation.XmlRootElement;

import com.zimbra.common.soap.AdminConstants;

/**
* @zm-api-command-auth-required true
* @zm-api-command-admin-auth-required true
* @zm-api-command-description Get all store managers
*/
@XmlRootElement(name=AdminConstants.E_GET_ALL_STORE_MANAGERS_REQUEST)
public class GetAllStoreManagersRequest {

public GetAllStoreManagersRequest() {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* ***** BEGIN LICENSE BLOCK *****
* Zimbra Collaboration Suite Server
* Copyright (C) 2022 Synacor, Inc.
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software Foundation,
* version 2 of the License.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
* You should have received a copy of the GNU General Public License along with this program.
* If not, see <https://www.gnu.org/licenses/>.
* ***** END LICENSE BLOCK *****
*/

package com.zimbra.soap.admin.message;

import com.google.common.collect.Lists;

import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

import com.zimbra.common.soap.AdminConstants;

@XmlAccessorType(XmlAccessType.NONE)
@XmlRootElement(name=AdminConstants.E_GET_ALL_STORE_MANAGERS_RESPONSE)
public final class GetAllStoreManagersResponse {

/**
* @zm-api-field-description Information about volumes
*/
@XmlElement(name=AdminConstants.E_STORE_MANAGER, required=true)
private final Set<String> smList = new HashSet<String>();


public void setSMList(Set<String> list) {
smList.clear();
if (list != null) {
smList.addAll(list);
}
}

public void addStoreManager(String smName) {
smList.add(smName);
}

public Set<String> getSMList() {
return smList;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* ***** BEGIN LICENSE BLOCK *****
* Zimbra Collaboration Suite Server
* Copyright (C) 2022 Synacor, Inc.
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software Foundation,
* version 2 of the License.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
* You should have received a copy of the GNU General Public License along with this program.
* If not, see <https://www.gnu.org/licenses/>.
* ***** END LICENSE BLOCK *****
*/
package com.zimbra.cs.service.admin;

import com.zimbra.common.service.ServiceException;
import com.zimbra.common.soap.Element;
import com.zimbra.cs.store.StoreManagerRegistrar;
import com.zimbra.soap.admin.message.GetAllStoreManagersRequest;
import com.zimbra.soap.admin.message.GetAllStoreManagersResponse;
import com.zimbra.soap.JaxbUtil;
import com.zimbra.soap.ZimbraSoapContext;
import java.util.Map;

public final class GetAllStoreManagers extends AdminDocumentHandler {

@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
ZimbraSoapContext zsc = getZimbraSoapContext(context);
GetAllStoreManagersRequest req = zsc.elementToJaxb(request);
GetAllStoreManagersResponse resp = new GetAllStoreManagersResponse();
resp.setSMList(StoreManagerRegistrar.getSMList());
return zsc.jaxbToElement(resp);
}
}
2 changes: 2 additions & 0 deletions store/src/java/com/zimbra/cs/store/StoreManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,15 @@
import com.zimbra.cs.mailbox.util.MailItemHelper;
import com.zimbra.cs.store.file.FileBlobStore;
import com.zimbra.cs.store.helper.ClassHelper;
import com.zimbra.cs.store.StoreManagerRegistrar;
import com.zimbra.cs.util.Zimbra;
import com.zimbra.cs.volume.VolumeManager;

import java.io.IOException;
import java.io.InputStream;
import java.util.Optional;


public abstract class StoreManager {

private static StoreManager sInstance;
Expand Down
36 changes: 36 additions & 0 deletions store/src/java/com/zimbra/cs/store/StoreManagerRegistrar.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* ***** BEGIN LICENSE BLOCK *****
* Zimbra Collaboration Suite Server
* Copyright (C) 2022 Synacor, Inc.
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software Foundation,
* version 2 of the License.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
* You should have received a copy of the GNU General Public License along with this program.
* If not, see <https://www.gnu.org/licenses/>.
* ***** END LICENSE BLOCK *****
*/
package com.zimbra.cs.store;
import com.zimbra.common.util.ZimbraLog;

import java.util.Set;

public abstract class StoreManagerRegistrar {

private static Set<String> smList;

public static void registerStoreManager(Class<? extends StoreManager> smTypeClass) {
String smName = smTypeClass.getClass().getSimpleName();
smList.add(smName);
System.out.print("Register store manager : " + smName);
ZimbraLog.misc.info("Register store manager : " + smName);
}

public static Set<String> getSMList() {
return smList;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;

import com.google.common.annotations.VisibleForTesting;
import com.zimbra.common.localconfig.LC;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import com.zimbra.common.service.ServiceException;
import com.zimbra.common.util.FileUtil;
import com.zimbra.cs.mailbox.Mailbox;
import com.zimbra.cs.store.StoreManagerRegistrar;

/**
* Simple ExternalStoreManager implementation that is intended for use in storing
Expand All @@ -37,7 +38,6 @@
*
*/
public class ImapTransientStoreManager extends ExternalStoreManager {

protected File baseDirectory;

@Override
Expand Down Expand Up @@ -85,5 +85,4 @@ private File createBlobFile(Mailbox mbox) throws IOException {
return File.createTempFile(mbox.getAccountId(), ".msg", baseDirectory);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,16 @@
import com.zimbra.common.util.FileUtil;
import com.zimbra.common.util.ZimbraLog;
import com.zimbra.cs.mailbox.Mailbox;
import com.zimbra.cs.store.StoreManagerRegistrar;

/**
* Example implementation of ExternalStoreManager which writes to a flat directory structure
* This is intended for illustration purposes only; it should *never* be used in a production environment
*
*/
public class SimpleStoreManager extends ExternalStoreManager {

String directory = null;

@Override
public void startup() throws IOException, ServiceException {
super.startup();
Expand Down
3 changes: 2 additions & 1 deletion store/src/java/com/zimbra/cs/store/file/FileBlobStore.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import com.zimbra.cs.store.MailboxBlob;
import com.zimbra.cs.store.StagedBlob;
import com.zimbra.cs.store.StoreManager;
import com.zimbra.cs.store.StoreManagerRegistrar;
import com.zimbra.cs.volume.Volume;
import com.zimbra.cs.volume.VolumeManager;
import com.zimbra.znative.IO;
Expand Down Expand Up @@ -443,7 +444,7 @@ private static void ensureParentDirExists(File file) throws IOException {
* specified by dest* parameters. Note this method is not part of the
* StoreManager interface It is only to be used for FileBlobStore specific code
* such as ExternalToInternal
*
*
* @param in
* @param storeAsIs
* @param mbox
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
import com.zimbra.cs.store.external.ExternalResumableUpload;
import com.zimbra.cs.store.external.ExternalUploadedBlob;
import com.zimbra.cs.store.external.SisStore;
import com.zimbra.cs.store.StoreManagerRegistrar;

/**
* StoreManager implementation which uses the TDS Blob API for storing and retrieving blobs
Expand Down
9 changes: 9 additions & 0 deletions store/src/java/com/zimbra/cs/util/Zimbra.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@
import com.zimbra.cs.session.WaitSetMgr;
import com.zimbra.cs.stats.ZimbraPerf;
import com.zimbra.cs.store.StoreManager;
import com.zimbra.cs.store.StoreManagerRegistrar;
import com.zimbra.cs.store.file.FileBlobStore;
import com.zimbra.cs.store.triton.TritonBlobStoreManager;
import com.zimbra.cs.store.external.ImapTransientStoreManager;
import com.zimbra.cs.store.external.ExternalStoreManager;
import com.zimbra.cs.zookeeper.CuratorManager;
import com.zimbra.znative.Util;

Expand Down Expand Up @@ -270,6 +275,10 @@ private static synchronized void startup(boolean forMailboxd) throws ServiceExce
} catch (IOException e) {
throw ServiceException.FAILURE("Unable to initialize StoreManager.", e);
}
StoreManagerRegistrar.registerStoreManager(FileBlobStore.class);
StoreManagerRegistrar.registerStoreManager(ExternalStoreManager.class);
StoreManagerRegistrar.registerStoreManager(TritonBlobStoreManager.class);
StoreManagerRegistrar.registerStoreManager(ImapTransientStoreManager.class);

MailboxManager.getInstance();

Expand Down