    public Object[] refreshDocument(DocumentRef ref, int refreshFlags,
            String[] schemas) throws ClientException {
        Object[] result = new Object[5];
        try {
            Document doc = resolveReference(ref);
            if (doc == null) {
                throw new ClientException("No Such Document: " + ref);
            }
            boolean readPermChecked = false;
            if ((refreshFlags & DocumentModel.REFRESH_PREFETCH) != 0) {
                if (!readPermChecked) {
                    checkPermission(doc, READ);
                    readPermChecked = true;
                }
                PrefetchInfo info = doc.getType().getPrefetchInfo();
                if (info != null) {
                    Schema[] pschemas = info.getSchemas();
                    if (pschemas != null) {
                    }
                    Field[] fields = info.getFields();
                    if (fields != null) {
                        Map<String, Serializable> prefetch = new HashMap<String, Serializable>();
                        for (Field field : fields) {
                            Object value = doc.getPropertyValue(field.getName().getPrefixedName());
                            prefetch.put(field.getDeclaringType().getName()
                                    + '.' + field.getName().getLocalName(),
                                    value == null ? Null.VALUE
                                            : (Serializable) value);
                        }
                        result[0] = prefetch;
                    }
                }
            }
            if ((refreshFlags & DocumentModel.REFRESH_LOCK) != 0) {
                if (!readPermChecked) {
                    checkPermission(doc, READ);
                    readPermChecked = true;
                }
                result[1] = doc.getLock();
            }
            if ((refreshFlags & DocumentModel.REFRESH_LIFE_CYCLE) != 0) {
                checkPermission(doc, READ_LIFE_CYCLE);
                result[2] = doc.getCurrentLifeCycleState();
                result[3] = doc.getLifeCyclePolicy();
            }
            if ((refreshFlags & DocumentModel.REFRESH_ACP) != 0) {
                checkPermission(doc, READ_SECURITY);
                result[4] = getSession().getSecurityManager().getMergedACP(doc);
            }
            if ((refreshFlags & (DocumentModel.REFRESH_CONTENT)) != 0) {
                if (!readPermChecked) {
                    checkPermission(doc, READ);
                    readPermChecked = true;
                }
                if (schemas == null) {
                    schemas = doc.getType().getSchemaNames();
                }
                DocumentType type = doc.getType();
                DocumentPart[] parts = new DocumentPart[schemas.length];
                for (int i = 0; i < schemas.length; i++) {
                    DocumentPart part = new DocumentPartImpl(
                            type.getSchema(schemas[i]));
                    doc.readDocumentPart(part);
                    parts[i] = part;
                }
                result[5] = parts;
            }
        } catch (ClientException e) {
            throw e;
        } catch (Exception e) {
            throw new ClientException("Failed to get refresh data", e);
        }
        return result;
    }

    public Object[] refreshDocument(DocumentRef ref, int refreshFlags,
            String[] schemas) throws ClientException {
        Object[] result = new Object[6];
        try {
            Document doc = resolveReference(ref);
            if (doc == null) {
                throw new ClientException("No Such Document: " + ref);
            }
            boolean readPermChecked = false;
            if ((refreshFlags & DocumentModel.REFRESH_PREFETCH) != 0) {
                if (!readPermChecked) {
                    checkPermission(doc, READ);
                    readPermChecked = true;
                }
                PrefetchInfo info = doc.getType().getPrefetchInfo();
                if (info != null) {
                    Schema[] pschemas = info.getSchemas();
                    if (pschemas != null) {
                    }
                    Field[] fields = info.getFields();
                    if (fields != null) {
                        Map<String, Serializable> prefetch = new HashMap<String, Serializable>();
                        for (Field field : fields) {
                            Object value = doc.getPropertyValue(field.getName().getPrefixedName());
                            prefetch.put(field.getDeclaringType().getName()
                                    + '.' + field.getName().getLocalName(),
                                    value == null ? Null.VALUE
                                            : (Serializable) value);
                        }
                        result[0] = prefetch;
                    }
                }
            }
            if ((refreshFlags & DocumentModel.REFRESH_LOCK) != 0) {
                if (!readPermChecked) {
                    checkPermission(doc, READ);
                    readPermChecked = true;
                }
                result[1] = doc.getLock();
            }
            if ((refreshFlags & DocumentModel.REFRESH_LIFE_CYCLE) != 0) {
                checkPermission(doc, READ_LIFE_CYCLE);
                result[2] = doc.getCurrentLifeCycleState();
                result[3] = doc.getLifeCyclePolicy();
            }
            if ((refreshFlags & DocumentModel.REFRESH_ACP) != 0) {
                checkPermission(doc, READ_SECURITY);
                result[4] = getSession().getSecurityManager().getMergedACP(doc);
            }
            if ((refreshFlags & (DocumentModel.REFRESH_CONTENT)) != 0) {
                if (!readPermChecked) {
                    checkPermission(doc, READ);
                    readPermChecked = true;
                }
                if (schemas == null) {
                    schemas = doc.getType().getSchemaNames();
                }
                DocumentType type = doc.getType();
                DocumentPart[] parts = new DocumentPart[schemas.length];
                for (int i = 0; i < schemas.length; i++) {
                    DocumentPart part = new DocumentPartImpl(
                            type.getSchema(schemas[i]));
                    doc.readDocumentPart(part);
                    parts[i] = part;
                }
                result[5] = parts;
            }
        } catch (ClientException e) {
            throw e;
        } catch (Exception e) {
            throw new ClientException("Failed to get refresh data", e);
        }
        return result;
    }
