Search in sources :

Example 46 with XMLElement

use of com.zimbra.common.soap.Element.XMLElement in project zm-mailbox by Zimbra.

the class BlobConsistencyUtil method checkMailbox.

private void checkMailbox(int mboxId, SoapProvisioning prov) throws ServiceException {
    XMLElement request = new XMLElement(AdminConstants.CHECK_BLOB_CONSISTENCY_REQUEST);
    for (short volumeId : volumeIds) {
        request.addElement(AdminConstants.E_VOLUME).addAttribute(AdminConstants.A_ID, volumeId);
    }
    request.addElement(AdminConstants.E_MAILBOX).addAttribute(AdminConstants.A_ID, mboxId);
    request.addAttribute(AdminConstants.A_CHECK_SIZE, !skipSizeCheck);
    request.addAttribute(AdminConstants.A_REPORT_USED_BLOBS, outputUsedBlobs || usedBlobWriter != null);
    Element response = prov.invoke(request);
    for (Element mboxEl : response.listElements(AdminConstants.E_MAILBOX)) {
        // Print results.
        BlobConsistencyChecker.Results results = new BlobConsistencyChecker.Results(mboxEl);
        for (BlobInfo blob : results.missingBlobs.values()) {
            System.out.format("Mailbox %d, item %d, rev %d, %s: blob not found.\n", results.mboxId, blob.itemId, blob.modContent, locatorText(blob));
        }
        for (BlobInfo blob : results.incorrectSize.values()) {
            System.out.format("Mailbox %d, item %d, rev %d, %s: incorrect data size.  Expected %d, was %d.  File size is %d.\n", results.mboxId, blob.itemId, blob.modContent, locatorText(blob), blob.dbSize, blob.fileDataSize, blob.fileSize);
        }
        for (BlobInfo blob : results.unexpectedBlobs.values()) {
            System.out.format("Mailbox %d, %s: unexpected blob.  File size is %d.\n", results.mboxId, locatorText(blob), blob.fileSize);
            if (unexpectedBlobWriter != null) {
                unexpectedBlobWriter.println(blob.path);
            }
        }
        for (BlobInfo blob : results.incorrectModContent.values()) {
            System.out.format("Mailbox %d, item %d, rev %d, %s: file has incorrect revision.\n", results.mboxId, blob.itemId, blob.modContent, locatorText(blob));
        }
        for (BlobInfo blob : results.usedBlobs.values()) {
            if (outputUsedBlobs) {
                System.out.format("Used blob: Mailbox %d, item %d, rev %d, %s.\n", results.mboxId, blob.itemId, blob.version, locatorText(blob));
            }
            if (usedBlobWriter != null) {
                usedBlobWriter.println(blob.path);
            }
        }
        // Fix inconsistencies.
        if (missingBlobDeleteItem && results.missingBlobs.size() > 0) {
            exportAndDelete(prov, results);
        }
        if (incorrectRevisionRenameFile) {
            for (BlobInfo blob : results.incorrectModContent.values()) {
                File file = new File(blob.path);
                File dir = file.getParentFile();
                if (dir != null) {
                    File newFile = new File(dir, FileBlobStore.getFilename(blob.itemId, blob.modContent));
                    System.out.format("Renaming %s to %s.\n", file.getAbsolutePath(), newFile.getAbsolutePath());
                    if (!file.renameTo(newFile)) {
                        System.err.format("Unable to rename %s to %s.\n", file.getAbsolutePath(), newFile.getAbsolutePath());
                    }
                } else {
                    System.err.format("Could not determine parent directory of %s.\n", file.getAbsolutePath());
                }
            }
        }
    }
}
Also used : XMLElement(com.zimbra.common.soap.Element.XMLElement) Element(com.zimbra.common.soap.Element) BlobInfo(com.zimbra.cs.store.file.BlobConsistencyChecker.BlobInfo) XMLElement(com.zimbra.common.soap.Element.XMLElement) File(java.io.File)

Example 47 with XMLElement

use of com.zimbra.common.soap.Element.XMLElement in project zm-mailbox by Zimbra.

the class TestAccess method SearchCalendarResources.

public void SearchCalendarResources(Role role, Perm perm) throws Exception {
    XMLElement req = new XMLElement(AccountConstants.SEARCH_CALENDAR_RESOURCES_REQUEST);
    Element sf = req.addElement(AccountConstants.E_ENTRY_SEARCH_FILTER);
    Element cond = sf.addElement(AccountConstants.E_ENTRY_SEARCH_FILTER_SINGLECOND);
    cond.addAttribute(AccountConstants.A_ENTRY_SEARCH_FILTER_ATTR, Provisioning.A_zimbraCalResType);
    cond.addAttribute(AccountConstants.A_ENTRY_SEARCH_FILTER_OP, "eq");
    cond.addAttribute(AccountConstants.A_ENTRY_SEARCH_FILTER_VALUE, "Equipment");
    accessTest(role, perm, req);
}
Also used : XMLElement(com.zimbra.common.soap.Element.XMLElement) Element(com.zimbra.common.soap.Element) XMLElement(com.zimbra.common.soap.Element.XMLElement)

Example 48 with XMLElement

use of com.zimbra.common.soap.Element.XMLElement in project zm-mailbox by Zimbra.

the class TestAccess method GetDataSourcess.

public void GetDataSourcess(Role role, Perm perm) throws Exception {
    XMLElement req = new XMLElement(MailConstants.GET_DATA_SOURCES_REQUEST);
    accessTest(role, perm, req);
}
Also used : XMLElement(com.zimbra.common.soap.Element.XMLElement)

Example 49 with XMLElement

use of com.zimbra.common.soap.Element.XMLElement in project zm-mailbox by Zimbra.

the class TestAccess method GetInfo.

public void GetInfo(Role role, Perm perm) throws Exception {
    XMLElement req = new XMLElement(AccountConstants.GET_INFO_REQUEST);
    accessTest(role, perm, req);
}
Also used : XMLElement(com.zimbra.common.soap.Element.XMLElement)

Example 50 with XMLElement

use of com.zimbra.common.soap.Element.XMLElement in project zm-mailbox by Zimbra.

the class TestAccess method AutoCompleteGal.

public void AutoCompleteGal(Role role, Perm perm) throws Exception {
    XMLElement req = new XMLElement(AccountConstants.AUTO_COMPLETE_GAL_REQUEST);
    req.addElement(AdminConstants.E_NAME).setText("phoebe");
    req.addAttribute(AdminConstants.A_TYPE, "all");
    req.addAttribute(AdminConstants.A_LIMIT, "10");
    accessTest(role, perm, req);
}
Also used : XMLElement(com.zimbra.common.soap.Element.XMLElement)

Aggregations

XMLElement (com.zimbra.common.soap.Element.XMLElement)140 Element (com.zimbra.common.soap.Element)111 Test (org.junit.Test)30 JSONElement (com.zimbra.common.soap.Element.JSONElement)29 XmlAnyElement (javax.xml.bind.annotation.XmlAnyElement)25 XmlElement (javax.xml.bind.annotation.XmlElement)25 FilterTest (com.zimbra.soap.mail.type.FilterTest)24 SoapHttpTransport (com.zimbra.common.soap.SoapHttpTransport)9 HashMap (java.util.HashMap)8 Account (com.zimbra.cs.account.Account)6 ArrayList (java.util.ArrayList)6 ZAuthToken (com.zimbra.common.auth.ZAuthToken)5 KeyValuePair (com.zimbra.soap.type.KeyValuePair)5 ByteBuilder (com.zimbra.common.mime.HeaderUtils.ByteBuilder)4 ServiceException (com.zimbra.common.service.ServiceException)4 DataSource (com.zimbra.cs.account.DataSource)4 Auth (com.zimbra.cs.service.account.Auth)4 URL (java.net.URL)4 Cookie (javax.servlet.http.Cookie)4 Signature (com.zimbra.cs.account.Signature)3