001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portal.lar;
016    
017    import com.liferay.portal.NoSuchRoleException;
018    import com.liferay.portal.NoSuchTeamException;
019    import com.liferay.portal.kernel.bean.BeanPropertiesUtil;
020    import com.liferay.portal.kernel.dao.orm.Conjunction;
021    import com.liferay.portal.kernel.dao.orm.Criterion;
022    import com.liferay.portal.kernel.dao.orm.DynamicQuery;
023    import com.liferay.portal.kernel.dao.orm.Property;
024    import com.liferay.portal.kernel.dao.orm.PropertyFactoryUtil;
025    import com.liferay.portal.kernel.dao.orm.RestrictionsFactoryUtil;
026    import com.liferay.portal.kernel.exception.PortalException;
027    import com.liferay.portal.kernel.exception.SystemException;
028    import com.liferay.portal.kernel.lar.ExportImportClassedModelUtil;
029    import com.liferay.portal.kernel.lar.ExportImportPathUtil;
030    import com.liferay.portal.kernel.lar.ExportImportThreadLocal;
031    import com.liferay.portal.kernel.lar.ManifestSummary;
032    import com.liferay.portal.kernel.lar.PortletDataContext;
033    import com.liferay.portal.kernel.lar.PortletDataContextListener;
034    import com.liferay.portal.kernel.lar.PortletDataHandlerControl;
035    import com.liferay.portal.kernel.lar.PortletDataHandlerKeys;
036    import com.liferay.portal.kernel.lar.StagedModelDataHandlerUtil;
037    import com.liferay.portal.kernel.lar.StagedModelType;
038    import com.liferay.portal.kernel.lar.UserIdStrategy;
039    import com.liferay.portal.kernel.log.Log;
040    import com.liferay.portal.kernel.log.LogFactoryUtil;
041    import com.liferay.portal.kernel.util.ArrayUtil;
042    import com.liferay.portal.kernel.util.DateRange;
043    import com.liferay.portal.kernel.util.GetterUtil;
044    import com.liferay.portal.kernel.util.HtmlUtil;
045    import com.liferay.portal.kernel.util.KeyValuePair;
046    import com.liferay.portal.kernel.util.ListUtil;
047    import com.liferay.portal.kernel.util.MapUtil;
048    import com.liferay.portal.kernel.util.PrimitiveLongList;
049    import com.liferay.portal.kernel.util.StringBundler;
050    import com.liferay.portal.kernel.util.StringPool;
051    import com.liferay.portal.kernel.util.StringUtil;
052    import com.liferay.portal.kernel.util.Validator;
053    import com.liferay.portal.kernel.workflow.WorkflowConstants;
054    import com.liferay.portal.kernel.xml.Attribute;
055    import com.liferay.portal.kernel.xml.Element;
056    import com.liferay.portal.kernel.xml.Node;
057    import com.liferay.portal.kernel.xml.SAXReaderUtil;
058    import com.liferay.portal.kernel.xml.XPath;
059    import com.liferay.portal.kernel.zip.ZipReader;
060    import com.liferay.portal.kernel.zip.ZipWriter;
061    import com.liferay.portal.model.AttachedModel;
062    import com.liferay.portal.model.AuditedModel;
063    import com.liferay.portal.model.ClassedModel;
064    import com.liferay.portal.model.Group;
065    import com.liferay.portal.model.Layout;
066    import com.liferay.portal.model.Lock;
067    import com.liferay.portal.model.OrgLabor;
068    import com.liferay.portal.model.Portlet;
069    import com.liferay.portal.model.PortletModel;
070    import com.liferay.portal.model.ResourceConstants;
071    import com.liferay.portal.model.ResourcedModel;
072    import com.liferay.portal.model.Role;
073    import com.liferay.portal.model.RoleConstants;
074    import com.liferay.portal.model.StagedGroupedModel;
075    import com.liferay.portal.model.StagedModel;
076    import com.liferay.portal.model.Team;
077    import com.liferay.portal.model.impl.LockImpl;
078    import com.liferay.portal.security.permission.ResourceActionsUtil;
079    import com.liferay.portal.service.GroupLocalServiceUtil;
080    import com.liferay.portal.service.LockLocalServiceUtil;
081    import com.liferay.portal.service.ResourceBlockLocalServiceUtil;
082    import com.liferay.portal.service.ResourceBlockPermissionLocalServiceUtil;
083    import com.liferay.portal.service.ResourcePermissionLocalServiceUtil;
084    import com.liferay.portal.service.RoleLocalServiceUtil;
085    import com.liferay.portal.service.ServiceContext;
086    import com.liferay.portal.service.TeamLocalServiceUtil;
087    import com.liferay.portal.util.PortalUtil;
088    import com.liferay.portal.util.PortletKeys;
089    import com.liferay.portal.util.PropsValues;
090    import com.liferay.portlet.asset.model.AssetCategory;
091    import com.liferay.portlet.asset.model.AssetEntry;
092    import com.liferay.portlet.asset.model.AssetLink;
093    import com.liferay.portlet.asset.model.AssetTag;
094    import com.liferay.portlet.asset.service.AssetCategoryLocalServiceUtil;
095    import com.liferay.portlet.asset.service.AssetEntryLocalServiceUtil;
096    import com.liferay.portlet.asset.service.AssetLinkLocalServiceUtil;
097    import com.liferay.portlet.asset.service.AssetTagLocalServiceUtil;
098    import com.liferay.portlet.blogs.model.impl.BlogsEntryImpl;
099    import com.liferay.portlet.bookmarks.model.impl.BookmarksEntryImpl;
100    import com.liferay.portlet.bookmarks.model.impl.BookmarksFolderImpl;
101    import com.liferay.portlet.documentlibrary.lar.xstream.FileEntryConverter;
102    import com.liferay.portlet.documentlibrary.lar.xstream.FileVersionConverter;
103    import com.liferay.portlet.documentlibrary.lar.xstream.FolderConverter;
104    import com.liferay.portlet.documentlibrary.model.impl.DLFileEntryImpl;
105    import com.liferay.portlet.documentlibrary.model.impl.DLFileShortcutImpl;
106    import com.liferay.portlet.documentlibrary.model.impl.DLFolderImpl;
107    import com.liferay.portlet.dynamicdatamapping.storage.Field;
108    import com.liferay.portlet.dynamicdatamapping.storage.Fields;
109    import com.liferay.portlet.expando.model.ExpandoBridge;
110    import com.liferay.portlet.expando.model.ExpandoColumn;
111    import com.liferay.portlet.expando.service.ExpandoColumnLocalServiceUtil;
112    import com.liferay.portlet.journal.model.impl.JournalArticleImpl;
113    import com.liferay.portlet.journal.model.impl.JournalFeedImpl;
114    import com.liferay.portlet.messageboards.model.MBDiscussion;
115    import com.liferay.portlet.messageboards.model.MBMessage;
116    import com.liferay.portlet.messageboards.model.MBThread;
117    import com.liferay.portlet.messageboards.model.impl.MBBanImpl;
118    import com.liferay.portlet.messageboards.model.impl.MBCategoryImpl;
119    import com.liferay.portlet.messageboards.model.impl.MBMessageImpl;
120    import com.liferay.portlet.messageboards.model.impl.MBThreadFlagImpl;
121    import com.liferay.portlet.messageboards.service.MBMessageLocalServiceUtil;
122    import com.liferay.portlet.messageboards.service.MBThreadLocalServiceUtil;
123    import com.liferay.portlet.messageboards.service.persistence.MBDiscussionUtil;
124    import com.liferay.portlet.messageboards.service.persistence.MBMessageUtil;
125    import com.liferay.portlet.polls.model.impl.PollsChoiceImpl;
126    import com.liferay.portlet.polls.model.impl.PollsQuestionImpl;
127    import com.liferay.portlet.polls.model.impl.PollsVoteImpl;
128    import com.liferay.portlet.ratings.model.RatingsEntry;
129    import com.liferay.portlet.ratings.model.impl.RatingsEntryImpl;
130    import com.liferay.portlet.ratings.service.RatingsEntryLocalServiceUtil;
131    import com.liferay.portlet.wiki.model.impl.WikiNodeImpl;
132    import com.liferay.portlet.wiki.model.impl.WikiPageImpl;
133    
134    import com.thoughtworks.xstream.XStream;
135    import com.thoughtworks.xstream.security.NoTypePermission;
136    import com.thoughtworks.xstream.security.PrimitiveTypePermission;
137    
138    import java.io.IOException;
139    import java.io.InputStream;
140    import java.io.Serializable;
141    
142    import java.math.BigDecimal;
143    
144    import java.sql.Time;
145    import java.sql.Timestamp;
146    
147    import java.util.ArrayList;
148    import java.util.Collections;
149    import java.util.Date;
150    import java.util.HashMap;
151    import java.util.HashSet;
152    import java.util.List;
153    import java.util.Locale;
154    import java.util.Map;
155    import java.util.Set;
156    
157    import jodd.bean.BeanUtil;
158    
159    /**
160     * <p>
161     * Holds context information that is used during exporting and importing portlet
162     * data.
163     * </p>
164     *
165     * @author Brian Wing Shun Chan
166     * @author Raymond Aug??
167     * @author Bruno Farache
168     * @author Alexander Chow
169     * @author Mate Thurzo
170     */
171    public class PortletDataContextImpl implements PortletDataContext {
172    
173            public PortletDataContextImpl() {
174                    initXStream();
175            }
176    
177            @Override
178            public void addAssetCategories(Class<?> clazz, long classPK)
179                    throws SystemException {
180    
181                    List<AssetCategory> assetCategories =
182                            AssetCategoryLocalServiceUtil.getCategories(
183                                    clazz.getName(), classPK);
184    
185                    _assetCategoryUuidsMap.put(
186                            getPrimaryKeyString(clazz, classPK),
187                            StringUtil.split(
188                                    ListUtil.toString(
189                                            assetCategories, AssetCategory.UUID_ACCESSOR)));
190                    _assetCategoryIdsMap.put(
191                            getPrimaryKeyString(clazz, classPK),
192                            StringUtil.split(
193                                    ListUtil.toString(
194                                            assetCategories, AssetCategory.CATEGORY_ID_ACCESSOR), 0L));
195            }
196    
197            @Override
198            public void addAssetCategories(
199                    String className, long classPK, long[] assetCategoryIds) {
200    
201                    _assetCategoryIdsMap.put(
202                            getPrimaryKeyString(className, classPK), assetCategoryIds);
203            }
204    
205            public void addAssetLinks(Class<?> clazz, long classPK)
206                    throws SystemException {
207    
208                    AssetEntry assetEntry = AssetEntryLocalServiceUtil.fetchEntry(
209                            clazz.getName(), classPK);
210    
211                    if (assetEntry == null) {
212                            return;
213                    }
214    
215                    List<AssetLink> directAssetLinks =
216                            AssetLinkLocalServiceUtil.getDirectLinks(assetEntry.getEntryId());
217    
218                    if (directAssetLinks.isEmpty()) {
219                            return;
220                    }
221    
222                    Map<Integer, List<AssetLink>> assetLinksMap =
223                            new HashMap<Integer, List<AssetLink>>();
224    
225                    for (AssetLink assetLink : directAssetLinks) {
226                            List<AssetLink> assetLinks = assetLinksMap.get(assetLink.getType());
227    
228                            if (assetLinks == null) {
229                                    assetLinks = new ArrayList<AssetLink>();
230    
231                                    assetLinksMap.put(assetLink.getType(), assetLinks);
232                            }
233    
234                            assetLinks.add(assetLink);
235                    }
236    
237                    for (Map.Entry<Integer, List<AssetLink>> entry :
238                                    assetLinksMap.entrySet()) {
239    
240                            _assetLinksMap.put(
241                                    getPrimaryKeyString(assetEntry.getClassUuid(), entry.getKey()),
242                                    entry.getValue());
243                    }
244            }
245    
246            @Override
247            public void addAssetTags(Class<?> clazz, long classPK)
248                    throws SystemException {
249    
250                    String[] tagNames = AssetTagLocalServiceUtil.getTagNames(
251                            clazz.getName(), classPK);
252    
253                    _assetTagNamesMap.put(getPrimaryKeyString(clazz, classPK), tagNames);
254            }
255    
256            @Override
257            public void addAssetTags(
258                    String className, long classPK, String[] assetTagNames) {
259    
260                    _assetTagNamesMap.put(
261                            getPrimaryKeyString(className, classPK), assetTagNames);
262            }
263    
264            @Override
265            public void addClassedModel(
266                            Element element, String path, ClassedModel classedModel)
267                    throws PortalException, SystemException {
268    
269                    addClassedModel(
270                            element, path, classedModel, classedModel.getModelClass());
271            }
272    
273            @Override
274            public void addClassedModel(
275                            Element element, String path, ClassedModel classedModel,
276                            Class<?> clazz)
277                    throws PortalException, SystemException {
278    
279                    element.addAttribute("path", path);
280    
281                    if (classedModel instanceof AttachedModel) {
282                            AttachedModel attachedModel = (AttachedModel)classedModel;
283    
284                            element.addAttribute("class-name", attachedModel.getClassName());
285                    }
286                    else if (BeanUtil.hasProperty(classedModel, "className")) {
287                            String className = BeanPropertiesUtil.getStringSilent(
288                                    classedModel, "className");
289    
290                            if (className != null) {
291                                    element.addAttribute("class-name", className);
292                            }
293                    }
294    
295                    if (isPathProcessed(path)) {
296                            return;
297                    }
298    
299                    if (classedModel instanceof AuditedModel) {
300                            AuditedModel auditedModel = (AuditedModel)classedModel;
301    
302                            auditedModel.setUserUuid(auditedModel.getUserUuid());
303                    }
304    
305                    if (isResourceMain(classedModel)) {
306                            long classPK = getClassPK(classedModel);
307    
308                            addAssetCategories(clazz, classPK);
309    
310                            if (classedModel instanceof ResourcedModel) {
311                                    updateAssetCategoriesPrimaryKeyString(clazz, classedModel);
312                            }
313    
314                            addAssetLinks(clazz, classPK);
315                            addAssetTags(clazz, classPK);
316                            addExpando(element, path, classedModel, clazz);
317                            addLocks(clazz, String.valueOf(classPK));
318                            addPermissions(clazz, classPK);
319    
320                            boolean portletDataAll = MapUtil.getBoolean(
321                                    getParameterMap(), PortletDataHandlerKeys.PORTLET_DATA_ALL);
322    
323                            if (portletDataAll ||
324                                    MapUtil.getBoolean(
325                                            getParameterMap(), PortletDataHandlerKeys.COMMENTS)) {
326    
327                                    addComments(clazz, classPK);
328                            }
329    
330                            if (portletDataAll ||
331                                    MapUtil.getBoolean(
332                                            getParameterMap(), PortletDataHandlerKeys.RATINGS)) {
333    
334                                    addRatingsEntries(clazz, classPK);
335                            }
336                    }
337    
338                    _references.add(getReferenceKey(classedModel));
339    
340                    addZipEntry(path, classedModel);
341            }
342    
343            /**
344             * @deprecated As of 6.2.0, replaced by {@link #addClassedModel(Element,
345             *             String, ClassedModel, Class)}
346             */
347            @Override
348            public void addClassedModel(
349                            Element element, String path, ClassedModel classedModel,
350                            Class<?> clazz, String namespace)
351                    throws PortalException, SystemException {
352    
353                    addClassedModel(element, path, classedModel, clazz);
354            }
355    
356            /**
357             * @deprecated As of 6.2.0, replaced by {@link #addClassedModel(Element,
358             *             String, ClassedModel)}
359             */
360            @Override
361            public void addClassedModel(
362                            Element element, String path, ClassedModel classedModel,
363                            String namespace)
364                    throws PortalException, SystemException {
365    
366                    addClassedModel(element, path, classedModel);
367            }
368    
369            @Override
370            public void addComments(Class<?> clazz, long classPK)
371                    throws SystemException {
372    
373                    long classNameId = PortalUtil.getClassNameId(clazz);
374    
375                    MBDiscussion discussion = MBDiscussionUtil.fetchByC_C(
376                            classNameId, classPK);
377    
378                    if (discussion == null) {
379                            return;
380                    }
381    
382                    List<MBMessage> messages = MBMessageLocalServiceUtil.getThreadMessages(
383                            discussion.getThreadId(), WorkflowConstants.STATUS_APPROVED);
384    
385                    if (messages.isEmpty()) {
386                            return;
387                    }
388    
389                    MBMessage firstMessage = messages.get(0);
390    
391                    if ((messages.size() == 1) && firstMessage.isRoot()) {
392                            return;
393                    }
394    
395                    for (MBMessage message : messages) {
396                            addRatingsEntries(MBDiscussion.class, message.getPrimaryKey());
397                    }
398    
399                    _commentsMap.put(getPrimaryKeyString(clazz, classPK), messages);
400            }
401    
402            @Override
403            public void addComments(
404                    String className, long classPK, List<MBMessage> messages) {
405    
406                    _commentsMap.put(getPrimaryKeyString(className, classPK), messages);
407            }
408    
409            /**
410             * @see #isWithinDateRange(Date)
411             */
412            @Override
413            public void addDateRangeCriteria(
414                    DynamicQuery dynamicQuery, String propertyName) {
415    
416                    Criterion criterion = getDateRangeCriteria(propertyName);
417    
418                    if (criterion == null) {
419                            return;
420                    }
421    
422                    dynamicQuery.add(criterion);
423            }
424    
425            @Override
426            public void addDeletionSystemEventStagedModelTypes(
427                    StagedModelType... stagedModelTypes) {
428    
429                    for (StagedModelType stagedModelType : stagedModelTypes) {
430                            _deletionSystemEventModelTypes.add(stagedModelType);
431                    }
432            }
433    
434            @Override
435            public void addExpando(
436                            Element element, String path, ClassedModel classedModel)
437                    throws PortalException, SystemException {
438    
439                    addExpando(element, path, classedModel, classedModel.getModelClass());
440            }
441    
442            @Override
443            public void addLocks(Class<?> clazz, String key)
444                    throws PortalException, SystemException {
445    
446                    if (!_locksMap.containsKey(getPrimaryKeyString(clazz, key)) &&
447                            LockLocalServiceUtil.isLocked(clazz.getName(), key)) {
448    
449                            Lock lock = LockLocalServiceUtil.getLock(clazz.getName(), key);
450    
451                            addLocks(clazz.getName(), key, lock);
452                    }
453            }
454    
455            @Override
456            public void addLocks(String className, String key, Lock lock) {
457                    _locksMap.put(getPrimaryKeyString(className, key), lock);
458            }
459    
460            @Override
461            public void addPermissions(Class<?> clazz, long classPK)
462                    throws PortalException, SystemException {
463    
464                    addPermissions(clazz.getName(), classPK);
465            }
466    
467            @Override
468            public void addPermissions(String resourceName, long resourcePK)
469                    throws PortalException, SystemException {
470    
471                    if (!MapUtil.getBoolean(
472                                    _parameterMap, PortletDataHandlerKeys.PERMISSIONS)) {
473    
474                            return;
475                    }
476    
477                    List<KeyValuePair> permissions = new ArrayList<KeyValuePair>();
478    
479                    List<Role> roles = RoleLocalServiceUtil.getGroupRelatedRoles(_groupId);
480    
481                    PrimitiveLongList roleIds = new PrimitiveLongList(roles.size());
482                    Map<Long, String> roleIdsToNames = new HashMap<Long, String>();
483    
484                    for (Role role : roles) {
485                            String roleName = role.getName();
486    
487                            int roleType = role.getType();
488    
489                            if ((roleType == RoleConstants.TYPE_PROVIDER) && role.isTeam()) {
490                                    Team team = TeamLocalServiceUtil.getTeam(role.getClassPK());
491    
492                                    roleName = PermissionExporter.ROLE_TEAM_PREFIX + team.getName();
493                            }
494    
495                            roleIds.add(role.getRoleId());
496                            roleIdsToNames.put(role.getRoleId(), roleName);
497                    }
498    
499                    List<String> actionIds = ResourceActionsUtil.getModelResourceActions(
500                            resourceName);
501    
502                    Map<Long, Set<String>> roleIdsToActionIds = getActionIds(
503                            _companyId, roleIds.getArray(), resourceName, resourcePK,
504                            actionIds);
505    
506                    for (Map.Entry<Long, String> entry : roleIdsToNames.entrySet()) {
507                            long roleId = entry.getKey();
508                            String name = entry.getValue();
509    
510                            Set<String> availableActionIds = roleIdsToActionIds.get(roleId);
511    
512                            if (availableActionIds == null) {
513                                    availableActionIds = Collections.emptySet();
514                            }
515    
516                            KeyValuePair permission = new KeyValuePair(
517                                    name, StringUtil.merge(availableActionIds));
518    
519                            permissions.add(permission);
520                    }
521    
522                    _permissionsMap.put(
523                            getPrimaryKeyString(resourceName, resourcePK), permissions);
524            }
525    
526            @Override
527            public void addPermissions(
528                    String resourceName, long resourcePK, List<KeyValuePair> permissions) {
529    
530                    _permissionsMap.put(
531                            getPrimaryKeyString(resourceName, resourcePK), permissions);
532            }
533    
534            @Override
535            public void addPortalPermissions() throws PortalException, SystemException {
536                    addPermissions(PortletKeys.PORTAL, getCompanyId());
537            }
538    
539            @Override
540            public void addPortletPermissions(String resourceName)
541                    throws PortalException, SystemException {
542    
543                    long groupId = getGroupId();
544    
545                    Group group = GroupLocalServiceUtil.getGroup(groupId);
546    
547                    if (group.isStagingGroup()) {
548                            if (group.isStagedRemotely()) {
549                                    groupId = group.getLiveGroupId();
550                            }
551                            else {
552                                    return;
553                            }
554                    }
555    
556                    addPermissions(resourceName, groupId);
557            }
558    
559            @Override
560            public boolean addPrimaryKey(Class<?> clazz, String primaryKey) {
561                    boolean value = hasPrimaryKey(clazz, primaryKey);
562    
563                    if (!value) {
564                            _primaryKeys.add(getPrimaryKeyString(clazz, primaryKey));
565                    }
566    
567                    return value;
568            }
569    
570            @Override
571            public void addRatingsEntries(Class<?> clazz, long classPK)
572                    throws SystemException {
573    
574                    List<RatingsEntry> ratingsEntries =
575                            RatingsEntryLocalServiceUtil.getEntries(clazz.getName(), classPK);
576    
577                    if (ratingsEntries.size() == 0) {
578                            return;
579                    }
580    
581                    _ratingsEntriesMap.put(
582                            getPrimaryKeyString(clazz, classPK), ratingsEntries);
583            }
584    
585            @Override
586            public void addRatingsEntries(
587                    String className, long classPK, List<RatingsEntry> ratingsEntries) {
588    
589                    _ratingsEntriesMap.put(
590                            getPrimaryKeyString(className, classPK), ratingsEntries);
591            }
592    
593            /**
594             * @deprecated As of 7.0.0, with no direct replacement
595             */
596            @Deprecated
597            @Override
598            public Element addReferenceElement(
599                    ClassedModel referrerClassedModel, Element element,
600                    ClassedModel classedModel, Class<?> clazz, String referenceType,
601                    boolean missing) {
602    
603                    return addReferenceElement(
604                            referrerClassedModel, element, classedModel, clazz.getName(),
605                            StringPool.BLANK, referenceType, missing);
606            }
607    
608            @Override
609            public Element addReferenceElement(
610                    ClassedModel referrerClassedModel, Element element,
611                    ClassedModel classedModel, String referenceType, boolean missing) {
612    
613                    return addReferenceElement(
614                            referrerClassedModel, element, classedModel,
615                            ExportImportClassedModelUtil.getClassName(classedModel),
616                            StringPool.BLANK, referenceType, missing);
617            }
618    
619            @Override
620            public Element addReferenceElement(
621                    ClassedModel referrerClassedModel, Element element,
622                    ClassedModel classedModel, String binPath, String referenceType,
623                    boolean missing) {
624    
625                    return addReferenceElement(
626                            referrerClassedModel, element, classedModel,
627                            ExportImportClassedModelUtil.getClassName(classedModel), binPath,
628                            referenceType, missing);
629            }
630    
631            @Override
632            public Element addReferenceElement(
633                    ClassedModel referrerClassedModel, Element element,
634                    ClassedModel classedModel, String className, String binPath,
635                    String referenceType, boolean missing) {
636    
637                    Element referenceElement = doAddReferenceElement(
638                            referrerClassedModel, element, classedModel, className, binPath,
639                            referenceType, false);
640    
641                    String referenceKey = getReferenceKey(classedModel);
642    
643                    if (missing) {
644                            if (_references.contains(referenceKey)) {
645                                    return referenceElement;
646                            }
647    
648                            referenceElement.addAttribute("missing", Boolean.TRUE.toString());
649    
650                            if (!_missingReferences.contains(referenceKey)) {
651                                    _missingReferences.add(referenceKey);
652    
653                                    doAddReferenceElement(
654                                            referrerClassedModel, null, classedModel, className,
655                                            binPath, referenceType, true);
656                            }
657                    }
658                    else {
659                            _references.add(referenceKey);
660    
661                            cleanUpMissingReferences(classedModel);
662                    }
663    
664                    return referenceElement;
665            }
666    
667            @Override
668            public boolean addScopedPrimaryKey(Class<?> clazz, String primaryKey) {
669                    boolean value = hasScopedPrimaryKey(clazz, primaryKey);
670    
671                    if (!value) {
672                            _scopedPrimaryKeys.add(getPrimaryKeyString(clazz, primaryKey));
673                    }
674    
675                    return value;
676            }
677    
678            @Override
679            public void addZipEntry(String path, byte[] bytes) throws SystemException {
680                    if (_portletDataContextListener != null) {
681                            _portletDataContextListener.onAddZipEntry(path);
682                    }
683    
684                    try {
685                            ZipWriter zipWriter = getZipWriter();
686    
687                            zipWriter.addEntry(path, bytes);
688                    }
689                    catch (IOException ioe) {
690                            throw new SystemException(ioe);
691                    }
692            }
693    
694            @Override
695            public void addZipEntry(String path, InputStream is)
696                    throws SystemException {
697    
698                    if (_portletDataContextListener != null) {
699                            _portletDataContextListener.onAddZipEntry(path);
700                    }
701    
702                    try {
703                            ZipWriter zipWriter = getZipWriter();
704    
705                            zipWriter.addEntry(path, is);
706                    }
707                    catch (IOException ioe) {
708                            throw new SystemException(ioe);
709                    }
710            }
711    
712            @Override
713            public void addZipEntry(String path, Object object) throws SystemException {
714                    addZipEntry(path, toXML(object));
715            }
716    
717            @Override
718            public void addZipEntry(String path, String s) throws SystemException {
719                    if (_portletDataContextListener != null) {
720                            _portletDataContextListener.onAddZipEntry(path);
721                    }
722    
723                    try {
724                            ZipWriter zipWriter = getZipWriter();
725    
726                            zipWriter.addEntry(path, s);
727                    }
728                    catch (IOException ioe) {
729                            throw new SystemException(ioe);
730                    }
731            }
732    
733            @Override
734            public void addZipEntry(String path, StringBuilder sb)
735                    throws SystemException {
736    
737                    if (_portletDataContextListener != null) {
738                            _portletDataContextListener.onAddZipEntry(path);
739                    }
740    
741                    try {
742                            ZipWriter zipWriter = getZipWriter();
743    
744                            zipWriter.addEntry(path, sb);
745                    }
746                    catch (IOException ioe) {
747                            throw new SystemException(ioe);
748                    }
749            }
750    
751            @Override
752            public void cleanUpMissingReferences(ClassedModel classedModel) {
753                    String referenceKey = getReferenceKey(classedModel);
754    
755                    if (_missingReferences.contains(referenceKey)) {
756                            _missingReferences.remove(referenceKey);
757    
758                            Element missingReferenceElement = getMissingReferenceElement(
759                                    classedModel);
760    
761                            _missingReferencesElement.remove(missingReferenceElement);
762                    }
763            }
764    
765            @Override
766            public void clearScopedPrimaryKeys() {
767                    _scopedPrimaryKeys.clear();
768            }
769    
770            @Override
771            public ServiceContext createServiceContext(
772                    Element element, ClassedModel classedModel) {
773    
774                    return createServiceContext(
775                            element, null, classedModel, classedModel.getModelClass());
776            }
777    
778            /**
779             * @deprecated As of 6.2.0, replaced by {@link
780             *             #createServiceContext(Element, ClassedModel)}
781             */
782            @Override
783            public ServiceContext createServiceContext(
784                    Element element, ClassedModel classedModel, String namespace) {
785    
786                    return createServiceContext(element, classedModel);
787            }
788    
789            @Override
790            public ServiceContext createServiceContext(StagedModel stagedModel) {
791    
792                    return createServiceContext(stagedModel, stagedModel.getModelClass());
793            }
794    
795            @Override
796            public ServiceContext createServiceContext(
797                    StagedModel stagedModel, Class<?> clazz) {
798    
799                    return createServiceContext(
800                            null, ExportImportPathUtil.getModelPath(stagedModel), stagedModel,
801                            clazz);
802            }
803    
804            @Override
805            public ServiceContext createServiceContext(
806                    String path, ClassedModel classedModel) {
807    
808                    return createServiceContext(
809                            null, path, classedModel, classedModel.getModelClass());
810            }
811    
812            /**
813             * @deprecated As of 6.2.0, replaced by {@link #createServiceContext(String,
814             *             ClassedModel)}
815             */
816            @Override
817            public ServiceContext createServiceContext(
818                    String path, ClassedModel classedModel, String namespace) {
819    
820                    return createServiceContext(path, classedModel);
821            }
822    
823            @Override
824            public Object fromXML(byte[] bytes) {
825                    if (ArrayUtil.isEmpty(bytes)) {
826                            return null;
827                    }
828    
829                    return _xStream.fromXML(new String(bytes));
830            }
831    
832            @Override
833            public Object fromXML(String xml) {
834                    if (Validator.isNull(xml)) {
835                            return null;
836                    }
837    
838                    return _xStream.fromXML(xml);
839            }
840    
841            @Override
842            public long[] getAssetCategoryIds(Class<?> clazz, long classPK) {
843                    return _assetCategoryIdsMap.get(getPrimaryKeyString(clazz, classPK));
844            }
845    
846            /**
847             * @deprecated As of 7.0.0
848             */
849            @Deprecated
850            @Override
851            public Map<String, long[]> getAssetCategoryIdsMap() {
852                    return _assetCategoryIdsMap;
853            }
854    
855            @Override
856            public Map<String, String[]> getAssetCategoryUuidsMap() {
857                    return _assetCategoryUuidsMap;
858            }
859    
860            @Override
861            public Map<String, List<AssetLink>> getAssetLinksMap() {
862                    return _assetLinksMap;
863            }
864    
865            @Override
866            public String[] getAssetTagNames(Class<?> clazz, long classPK) {
867                    return _assetTagNamesMap.get(getPrimaryKeyString(clazz, classPK));
868            }
869    
870            @Override
871            public String[] getAssetTagNames(String className, long classPK) {
872                    return _assetTagNamesMap.get(getPrimaryKeyString(className, classPK));
873            }
874    
875            @Override
876            public Map<String, String[]> getAssetTagNamesMap() {
877                    return _assetTagNamesMap;
878            }
879    
880            @Override
881            public boolean getBooleanParameter(String namespace, String name) {
882                    return getBooleanParameter(namespace, name, true);
883            }
884    
885            @Override
886            public boolean getBooleanParameter(
887                    String namespace, String name, boolean useDefaultValue) {
888    
889                    if (!useDefaultValue) {
890                            return MapUtil.getBoolean(
891                                    getParameterMap(),
892                                    PortletDataHandlerControl.getNamespacedControlName(
893                                            namespace, name));
894                    }
895    
896                    boolean defaultValue = MapUtil.getBoolean(
897                            getParameterMap(),
898                            PortletDataHandlerKeys.PORTLET_DATA_CONTROL_DEFAULT, true);
899    
900                    return MapUtil.getBoolean(
901                            getParameterMap(),
902                            PortletDataHandlerControl.getNamespacedControlName(namespace, name),
903                            defaultValue);
904            }
905    
906            @Override
907            public ClassLoader getClassLoader() {
908                    return _xStream.getClassLoader();
909            }
910    
911            @Override
912            public Map<String, List<MBMessage>> getComments() {
913                    return _commentsMap;
914            }
915    
916            @Override
917            public long getCompanyGroupId() {
918                    return _companyGroupId;
919            }
920    
921            @Override
922            public long getCompanyId() {
923                    return _companyId;
924            }
925    
926            @Override
927            public String getDataStrategy() {
928                    return _dataStrategy;
929            }
930    
931            @Override
932            public DateRange getDateRange() {
933                    DateRange dateRange = null;
934    
935                    if (hasDateRange()) {
936                            dateRange = new DateRange(_startDate, _endDate);
937                    }
938    
939                    return dateRange;
940            }
941    
942            @Override
943            public Criterion getDateRangeCriteria(String propertyName) {
944                    if (!hasDateRange()) {
945                            return null;
946                    }
947    
948                    Conjunction conjunction = RestrictionsFactoryUtil.conjunction();
949    
950                    Property property = PropertyFactoryUtil.forName(propertyName);
951    
952                    conjunction.add(property.le(_endDate));
953                    conjunction.add(property.ge(_startDate));
954    
955                    return conjunction;
956            }
957    
958            @Override
959            public Set<StagedModelType> getDeletionSystemEventStagedModelTypes() {
960                    return _deletionSystemEventModelTypes;
961            }
962    
963            @Override
964            public Date getEndDate() {
965                    return _endDate;
966            }
967    
968            @Override
969            public Map<String, List<ExpandoColumn>> getExpandoColumns() {
970                    return _expandoColumnsMap;
971            }
972    
973            @Override
974            public Element getExportDataElement(ClassedModel classedModel) {
975                    return getExportDataElement(
976                            classedModel,
977                            ExportImportClassedModelUtil.getClassSimpleName(classedModel));
978            }
979    
980            /**
981             * @deprecated As of 7.0.0, replaced by {@link
982             *             #getExportDataElement(ClassedModel, String)}
983             */
984            @Deprecated
985            @Override
986            public Element getExportDataElement(
987                    ClassedModel classedModel, Class<?> modelClass) {
988    
989                    return getExportDataElement(classedModel, modelClass.getSimpleName());
990            }
991    
992            @Override
993            public Element getExportDataElement(
994                    ClassedModel classedModel, String modelClassSimpleName) {
995    
996                    Element groupElement = getExportDataGroupElement(modelClassSimpleName);
997    
998                    Element element = null;
999    
1000                    if (classedModel instanceof StagedModel) {
1001                            StagedModel stagedModel = (StagedModel)classedModel;
1002    
1003                            String path = ExportImportPathUtil.getModelPath(stagedModel);
1004    
1005                            element = getDataElement(groupElement, "path", path);
1006    
1007                            if (element != null) {
1008                                    return element;
1009                            }
1010    
1011                            element = getDataElement(
1012                                    groupElement, "uuid", stagedModel.getUuid());
1013    
1014                            if (element != null) {
1015                                    return element;
1016                            }
1017                    }
1018    
1019                    element = groupElement.addElement("staged-model");
1020    
1021                    if (classedModel instanceof StagedGroupedModel) {
1022                            StagedGroupedModel stagedGroupedModel =
1023                                    (StagedGroupedModel)classedModel;
1024    
1025                            element.addAttribute(
1026                                    "group-id",String.valueOf(stagedGroupedModel.getGroupId()));
1027                            element.addAttribute("uuid", stagedGroupedModel.getUuid());
1028                    }
1029                    else if (classedModel instanceof StagedModel) {
1030                            StagedModel stagedModel = (StagedModel)classedModel;
1031    
1032                            element.addAttribute("uuid", stagedModel.getUuid());
1033                    }
1034    
1035                    return element;
1036            }
1037    
1038            @Override
1039            public Element getExportDataGroupElement(
1040                    Class<? extends StagedModel> clazz) {
1041    
1042                    return getExportDataGroupElement(clazz.getSimpleName());
1043            }
1044    
1045            @Override
1046            public Element getExportDataRootElement() {
1047                    return _exportDataRootElement;
1048            }
1049    
1050            @Override
1051            public long getGroupId() {
1052                    return _groupId;
1053            }
1054    
1055            @Override
1056            public Element getImportDataElement(StagedModel stagedModel) {
1057                    return getImportDataElement(
1058                            ExportImportClassedModelUtil.getClassSimpleName(stagedModel),
1059                            "uuid", stagedModel.getUuid());
1060            }
1061    
1062            @Override
1063            public Element getImportDataElement(
1064                    String name, String attribute, String value) {
1065    
1066                    Element groupElement = getImportDataGroupElement(name);
1067    
1068                    return getDataElement(groupElement, attribute, value);
1069            }
1070    
1071            @Override
1072            public Element getImportDataGroupElement(
1073                    Class<? extends StagedModel> clazz) {
1074    
1075                    return getImportDataGroupElement(clazz.getSimpleName());
1076            }
1077    
1078            @Override
1079            public Element getImportDataRootElement() {
1080                    return _importDataRootElement;
1081            }
1082    
1083            @Override
1084            public Element getImportDataStagedModelElement(StagedModel stagedModel) {
1085                    String path = ExportImportPathUtil.getModelPath(stagedModel);
1086    
1087                    return getImportDataElement(
1088                            ExportImportClassedModelUtil.getClassSimpleName(stagedModel),
1089                            "path", path);
1090            }
1091    
1092            @Override
1093            public String getLayoutPath(long plid) {
1094                    return ExportImportPathUtil.getLayoutPath(this, plid);
1095            }
1096    
1097            @Override
1098            public Map<String, Lock> getLocks() {
1099                    return _locksMap;
1100            }
1101    
1102            @Override
1103            public ManifestSummary getManifestSummary() {
1104                    return _manifestSummary;
1105            }
1106    
1107            @Override
1108            public Element getMissingReferencesElement() {
1109                    return _missingReferencesElement;
1110            }
1111    
1112            @Override
1113            public List<Layout> getNewLayouts() {
1114                    return _newLayouts;
1115            }
1116    
1117            @Override
1118            public Map<?, ?> getNewPrimaryKeysMap(Class<?> clazz) {
1119                    return getNewPrimaryKeysMap(clazz.getName());
1120            }
1121    
1122            @Override
1123            public Map<String, Map<?, ?>> getNewPrimaryKeysMaps() {
1124                    return _newPrimaryKeysMaps;
1125            }
1126    
1127            @Override
1128            public Map<?, ?> getNewPrimaryKeysMap(String className) {
1129                    Map<?, ?> map = _newPrimaryKeysMaps.get(className);
1130    
1131                    if (map == null) {
1132                            map = new HashMap<Object, Object>();
1133    
1134                            _newPrimaryKeysMaps.put(className, map);
1135                    }
1136    
1137                    return map;
1138            }
1139    
1140            /**
1141             * @deprecated As of 7.0.0
1142             */
1143            @Deprecated
1144            @Override
1145            public long getOldPlid() {
1146                    return _oldPlid;
1147            }
1148    
1149            @Override
1150            public Map<String, String[]> getParameterMap() {
1151                    return _parameterMap;
1152            }
1153    
1154            @Override
1155            public Map<String, List<KeyValuePair>> getPermissions() {
1156                    return _permissionsMap;
1157            }
1158    
1159            @Override
1160            public long getPlid() {
1161                    return _plid;
1162            }
1163    
1164            @Override
1165            public String getRootPortletId() {
1166                    return _rootPortletId;
1167            }
1168    
1169            @Override
1170            public String getPortletPath(String portletId) {
1171                    return ExportImportPathUtil.getPortletPath(this, portletId);
1172            }
1173    
1174            @Override
1175            public Set<String> getPrimaryKeys() {
1176                    return _primaryKeys;
1177            }
1178    
1179            @Override
1180            public Map<String, List<RatingsEntry>> getRatingsEntries() {
1181                    return _ratingsEntriesMap;
1182            }
1183    
1184            @Override
1185            public Element getReferenceDataElement(
1186                    Element parentElement, Class<?> clazz, long classPK) {
1187    
1188                    List<Element> referenceElements = getReferenceElements(
1189                            parentElement, clazz, 0, null, classPK, null);
1190    
1191                    List<Element> referenceDataElements = getReferenceDataElements(
1192                            referenceElements, clazz);
1193    
1194                    if (referenceDataElements.isEmpty()) {
1195                            return null;
1196                    }
1197    
1198                    return referenceDataElements.get(0);
1199            }
1200    
1201            @Override
1202            public Element getReferenceDataElement(
1203                    Element parentElement, Class<?> clazz, long groupId, String uuid) {
1204    
1205                    List<Element> referenceElements = getReferenceElements(
1206                            parentElement, clazz, groupId, uuid, 0, null);
1207    
1208                    List<Element> referenceDataElements = getReferenceDataElements(
1209                            referenceElements, clazz);
1210    
1211                    if (referenceDataElements.isEmpty()) {
1212                            return null;
1213                    }
1214    
1215                    return referenceDataElements.get(0);
1216            }
1217    
1218            @Override
1219            public Element getReferenceDataElement(
1220                    StagedModel parentStagedModel, Class<?> clazz, long classPK) {
1221    
1222                    Element parentElement = getImportDataStagedModelElement(
1223                            parentStagedModel);
1224    
1225                    return getReferenceDataElement(parentElement, clazz, classPK);
1226            }
1227    
1228            @Override
1229            public Element getReferenceDataElement(
1230                    StagedModel parentStagedModel, Class<?> clazz, long groupId,
1231                    String uuid) {
1232    
1233                    Element parentElement = getImportDataStagedModelElement(
1234                            parentStagedModel);
1235    
1236                    return getReferenceDataElement(parentElement, clazz, groupId, uuid);
1237            }
1238    
1239            /**
1240             * @deprecated As of 7.0.0
1241             */
1242            @Deprecated
1243            @Override
1244            public List<Element> getReferenceDataElements(
1245                    Element parentElement, Class<?> clazz) {
1246    
1247                    return getReferenceDataElements(parentElement, clazz, null);
1248            }
1249    
1250            @Override
1251            public List<Element> getReferenceDataElements(
1252                    Element parentElement, Class<?> clazz, String referenceType) {
1253    
1254                    List<Element> referenceElements = getReferenceElements(
1255                            parentElement, clazz, 0, null, 0, referenceType);
1256    
1257                    return getReferenceDataElements(referenceElements, clazz);
1258            }
1259    
1260            @Override
1261            public List<Element> getReferenceDataElements(
1262                    StagedModel parentStagedModel, Class<?> clazz) {
1263    
1264                    return getReferenceDataElements(parentStagedModel, clazz, null);
1265            }
1266    
1267            @Override
1268            public List<Element> getReferenceDataElements(
1269                    StagedModel parentStagedModel, Class<?> clazz, String referenceType) {
1270    
1271                    List<Element> referenceElements = getReferenceElements(
1272                            parentStagedModel, clazz, 0, referenceType);
1273    
1274                    return getReferenceDataElements(referenceElements, clazz);
1275            }
1276    
1277            @Override
1278            public Element getReferenceElement(
1279                    Element parentElement, Class<?> clazz, long groupId, String uuid,
1280                    String referenceType) {
1281    
1282                    List<Element> referenceElements = getReferenceElements(
1283                            parentElement, clazz, groupId, uuid, 0, referenceType);
1284    
1285                    if (!referenceElements.isEmpty()) {
1286                            return referenceElements.get(0);
1287                    }
1288    
1289                    return null;
1290            }
1291    
1292            @Override
1293            public Element getReferenceElement(
1294                    StagedModel parentStagedModel, Class<?> clazz, long classPK) {
1295    
1296                    List<Element> referenceElements = getReferenceElements(
1297                            parentStagedModel, clazz, classPK, null);
1298    
1299                    if (!referenceElements.isEmpty()) {
1300                            return referenceElements.get(0);
1301                    }
1302    
1303                    return null;
1304            }
1305    
1306            @Override
1307            public List<Element> getReferenceElements(
1308                    StagedModel parentStagedModel, Class<?> clazz) {
1309    
1310                    return getReferenceElements(parentStagedModel, clazz, 0, null);
1311            }
1312    
1313            @Override
1314            public String getRootPath() {
1315                    return ExportImportPathUtil.getRootPath(this);
1316            }
1317    
1318            /**
1319             * @deprecated As of 7.0.0
1320             */
1321            @Deprecated
1322            @Override
1323            public Set<String> getScopedPrimaryKeys() {
1324                    return _scopedPrimaryKeys;
1325            }
1326    
1327            @Override
1328            public long getScopeGroupId() {
1329                    return _scopeGroupId;
1330            }
1331    
1332            @Override
1333            public String getScopeLayoutUuid() {
1334                    return _scopeLayoutUuid;
1335            }
1336    
1337            @Override
1338            public String getScopeType() {
1339                    return _scopeType;
1340            }
1341    
1342            @Override
1343            public long getSourceCompanyGroupId() {
1344                    return _sourceCompanyGroupId;
1345            }
1346    
1347            @Override
1348            public long getSourceCompanyId() {
1349                    return _sourceCompanyId;
1350            }
1351    
1352            @Override
1353            public long getSourceGroupId() {
1354                    return _sourceGroupId;
1355            }
1356    
1357            @Override
1358            public String getSourceLayoutPath(long layoutId) {
1359                    return ExportImportPathUtil.getSourceLayoutPath(this, layoutId);
1360            }
1361    
1362            @Override
1363            public String getSourcePortletPath(String portletId) {
1364                    return ExportImportPathUtil.getSourcePortletPath(this, portletId);
1365            }
1366    
1367            @Override
1368            public String getSourceRootPath() {
1369                    return ExportImportPathUtil.getSourceRootPath(this);
1370            }
1371    
1372            @Override
1373            public long getSourceUserPersonalSiteGroupId() {
1374                    return _sourceUserPersonalSiteGroupId;
1375            }
1376    
1377            @Override
1378            public Date getStartDate() {
1379                    return _startDate;
1380            }
1381    
1382            @Override
1383            public long getUserId(String userUuid) {
1384                    return _userIdStrategy.getUserId(userUuid);
1385            }
1386    
1387            @Override
1388            public UserIdStrategy getUserIdStrategy() {
1389                    return _userIdStrategy;
1390            }
1391    
1392            @Override
1393            public long getUserPersonalSiteGroupId() {
1394                    return _userPersonalSiteGroupId;
1395            }
1396    
1397            /**
1398             * @deprecated As of 7.0.0
1399             */
1400            @Deprecated
1401            @Override
1402            public List<String> getZipEntries() {
1403                    return getZipReader().getEntries();
1404            }
1405    
1406            @Override
1407            public byte[] getZipEntryAsByteArray(String path) {
1408                    if (!Validator.isFilePath(path, false)) {
1409                            return null;
1410                    }
1411    
1412                    if (_portletDataContextListener != null) {
1413                            _portletDataContextListener.onGetZipEntry(path);
1414                    }
1415    
1416                    return getZipReader().getEntryAsByteArray(path);
1417            }
1418    
1419            @Override
1420            public InputStream getZipEntryAsInputStream(String path) {
1421                    if (!Validator.isFilePath(path, false)) {
1422                            return null;
1423                    }
1424    
1425                    if (_portletDataContextListener != null) {
1426                            _portletDataContextListener.onGetZipEntry(path);
1427                    }
1428    
1429                    return getZipReader().getEntryAsInputStream(path);
1430            }
1431    
1432            @Override
1433            public Object getZipEntryAsObject(Element element, String path) {
1434                    Object object = fromXML(getZipEntryAsString(path));
1435    
1436                    Attribute classNameAttribute = element.attribute("class-name");
1437    
1438                    if (classNameAttribute != null) {
1439                            BeanPropertiesUtil.setProperty(
1440                                    object, "className", classNameAttribute.getText());
1441                    }
1442    
1443                    return object;
1444            }
1445    
1446            @Override
1447            public Object getZipEntryAsObject(String path) {
1448                    return fromXML(getZipEntryAsString(path));
1449            }
1450    
1451            @Override
1452            public String getZipEntryAsString(String path) {
1453                    if (!Validator.isFilePath(path, false)) {
1454                            return null;
1455                    }
1456    
1457                    if (_portletDataContextListener != null) {
1458                            _portletDataContextListener.onGetZipEntry(path);
1459                    }
1460    
1461                    return getZipReader().getEntryAsString(path);
1462            }
1463    
1464            /**
1465             * @deprecated As of 7.0.0
1466             */
1467            @Deprecated
1468            @Override
1469            public List<String> getZipFolderEntries() {
1470                    return getZipFolderEntries(StringPool.SLASH);
1471            }
1472    
1473            @Override
1474            public List<String> getZipFolderEntries(String path) {
1475                    if (!Validator.isFilePath(path, false)) {
1476                            return null;
1477                    }
1478    
1479                    return getZipReader().getFolderEntries(path);
1480            }
1481    
1482            @Override
1483            public ZipReader getZipReader() {
1484                    return _zipReader;
1485            }
1486    
1487            @Override
1488            public ZipWriter getZipWriter() {
1489                    return _zipWriter;
1490            }
1491    
1492            @Override
1493            public boolean hasDateRange() {
1494                    if (_startDate != null) {
1495                            return true;
1496                    }
1497                    else {
1498                            return false;
1499                    }
1500            }
1501    
1502            @Override
1503            public boolean hasNotUniquePerLayout(String dataKey) {
1504                    return _notUniquePerLayout.contains(dataKey);
1505            }
1506    
1507            @Override
1508            public boolean hasPrimaryKey(Class<?> clazz, String primaryKey) {
1509                    return _primaryKeys.contains(getPrimaryKeyString(clazz, primaryKey));
1510            }
1511    
1512            @Override
1513            public boolean hasScopedPrimaryKey(Class<?> clazz, String primaryKey) {
1514                    return _scopedPrimaryKeys.contains(
1515                            getPrimaryKeyString(clazz, primaryKey));
1516            }
1517    
1518            @Override
1519            public void importClassedModel(
1520                            ClassedModel classedModel, ClassedModel newClassedModel)
1521                    throws PortalException, SystemException {
1522    
1523                    importClassedModel(
1524                            classedModel, newClassedModel, classedModel.getModelClass());
1525            }
1526    
1527            @Override
1528            public void importClassedModel(
1529                            ClassedModel classedModel, ClassedModel newClassedModel,
1530                            Class<?> clazz)
1531                    throws PortalException, SystemException {
1532    
1533                    if (!isResourceMain(classedModel)) {
1534                            return;
1535                    }
1536    
1537                    long classPK = getClassPK(classedModel);
1538    
1539                    long newClassPK = getClassPK(newClassedModel);
1540    
1541                    Map<Long, Long> newPrimaryKeysMap =
1542                            (Map<Long, Long>)getNewPrimaryKeysMap(clazz);
1543    
1544                    newPrimaryKeysMap.put(classPK, newClassPK);
1545    
1546                    importLocks(clazz, String.valueOf(classPK), String.valueOf(newClassPK));
1547                    importPermissions(clazz, classPK, newClassPK);
1548    
1549                    boolean portletDataAll = MapUtil.getBoolean(
1550                            getParameterMap(), PortletDataHandlerKeys.PORTLET_DATA_ALL);
1551    
1552                    if (portletDataAll ||
1553                            MapUtil.getBoolean(
1554                                    getParameterMap(), PortletDataHandlerKeys.COMMENTS)) {
1555    
1556                            importComments(clazz, classPK, newClassPK, getScopeGroupId());
1557                    }
1558    
1559                    if (portletDataAll ||
1560                            MapUtil.getBoolean(
1561                                    getParameterMap(), PortletDataHandlerKeys.RATINGS)) {
1562    
1563                            importRatingsEntries(clazz, classPK, newClassPK);
1564                    }
1565            }
1566    
1567            /**
1568             * @deprecated As of 6.2.0, replaced by {@link
1569             *             #importClassedModel(ClassedModel, ClassedModel, Class)}
1570             */
1571            @Override
1572            public void importClassedModel(
1573                            ClassedModel classedModel, ClassedModel newClassedModel,
1574                            Class<?> clazz, String namespace)
1575                    throws PortalException, SystemException {
1576    
1577                    importClassedModel(classedModel, newClassedModel, clazz);
1578            }
1579    
1580            /**
1581             * @deprecated As of 6.2.0, replaced by {@link
1582             *             #importClassedModel(ClassedModel, ClassedModel)}
1583             */
1584            @Override
1585            public void importClassedModel(
1586                            ClassedModel classedModel, ClassedModel newClassedModel,
1587                            String namespace)
1588                    throws PortalException, SystemException {
1589    
1590                    importClassedModel(
1591                            classedModel, newClassedModel, classedModel.getModelClass());
1592            }
1593    
1594            @Override
1595            public void importComments(
1596                            Class<?> clazz, long classPK, long newClassPK, long groupId)
1597                    throws PortalException, SystemException {
1598    
1599                    Map<Long, Long> messagePKs = new HashMap<Long, Long>();
1600                    Map<Long, Long> threadPKs = new HashMap<Long, Long>();
1601    
1602                    List<MBMessage> messages = _commentsMap.get(
1603                            getPrimaryKeyString(clazz, classPK));
1604    
1605                    if ((messages == null) || messages.isEmpty()) {
1606                            return;
1607                    }
1608    
1609                    MBMessage firstMessage = messages.get(0);
1610    
1611                    if ((messages.size() == 1) && firstMessage.isRoot()) {
1612                            return;
1613                    }
1614    
1615                    long classNameId = PortalUtil.getClassNameId(clazz);
1616    
1617                    MBDiscussion discussion = MBDiscussionUtil.fetchByC_C(
1618                            classNameId, newClassPK);
1619    
1620                    for (MBMessage message : messages) {
1621                            long userId = getUserId(message.getUserUuid());
1622                            long parentMessageId = MapUtil.getLong(
1623                                    messagePKs, message.getParentMessageId(),
1624                                    message.getParentMessageId());
1625                            long threadId = MapUtil.getLong(
1626                                    threadPKs, message.getThreadId(), message.getThreadId());
1627    
1628                            if (message.isRoot()) {
1629                                    if (discussion != null) {
1630                                            MBThread thread = MBThreadLocalServiceUtil.getThread(
1631                                                    discussion.getThreadId());
1632    
1633                                            long rootMessageId = thread.getRootMessageId();
1634    
1635                                            messagePKs.put(message.getMessageId(), rootMessageId);
1636                                            threadPKs.put(message.getThreadId(), thread.getThreadId());
1637                                    }
1638                                    else if (clazz == Layout.class) {
1639                                            MBMessage importedMessage =
1640                                                    MBMessageLocalServiceUtil.addDiscussionMessage(
1641                                                            userId, message.getUserName(), groupId,
1642                                                            clazz.getName(), newClassPK,
1643                                                            WorkflowConstants.ACTION_PUBLISH);
1644    
1645                                            messagePKs.put(
1646                                                    message.getMessageId(), importedMessage.getMessageId());
1647                                            threadPKs.put(
1648                                                    message.getThreadId(), importedMessage.getThreadId());
1649                                    }
1650                            }
1651                            else {
1652                                    ServiceContext serviceContext = new ServiceContext();
1653    
1654                                    serviceContext.setCreateDate(message.getCreateDate());
1655                                    serviceContext.setModifiedDate(message.getModifiedDate());
1656                                    serviceContext.setScopeGroupId(groupId);
1657    
1658                                    MBMessage importedMessage = null;
1659    
1660                                    if (_dataStrategy.equals(
1661                                                    PortletDataHandlerKeys.DATA_STRATEGY_MIRROR) ||
1662                                            _dataStrategy.equals(
1663                                                    PortletDataHandlerKeys.
1664                                                            DATA_STRATEGY_MIRROR_OVERWRITE)) {
1665    
1666                                            MBMessage existingMessage = MBMessageUtil.fetchByUUID_G(
1667                                                    message.getUuid(), groupId);
1668    
1669                                            if (existingMessage == null) {
1670                                                    serviceContext.setUuid(message.getUuid());
1671    
1672                                                    importedMessage =
1673                                                            MBMessageLocalServiceUtil.addDiscussionMessage(
1674                                                                    userId, message.getUserName(), groupId,
1675                                                                    clazz.getName(), newClassPK, threadId,
1676                                                                    parentMessageId, message.getSubject(),
1677                                                                    message.getBody(), serviceContext);
1678                                            }
1679                                            else {
1680                                                    serviceContext.setWorkflowAction(
1681                                                            WorkflowConstants.ACTION_PUBLISH);
1682    
1683                                                    importedMessage =
1684                                                            MBMessageLocalServiceUtil.updateDiscussionMessage(
1685                                                                    userId, existingMessage.getMessageId(),
1686                                                                    clazz.getName(), newClassPK,
1687                                                                    message.getSubject(), message.getBody(),
1688                                                                    serviceContext);
1689                                            }
1690                                    }
1691                                    else {
1692                                            importedMessage =
1693                                                    MBMessageLocalServiceUtil.addDiscussionMessage(
1694                                                            userId, message.getUserName(), groupId,
1695                                                            clazz.getName(), newClassPK, threadId,
1696                                                            parentMessageId, message.getSubject(),
1697                                                            message.getBody(), serviceContext);
1698                                    }
1699    
1700                                    messagePKs.put(
1701                                            message.getMessageId(), importedMessage.getMessageId());
1702                                    threadPKs.put(
1703                                            message.getThreadId(), importedMessage.getThreadId());
1704                            }
1705    
1706                            importRatingsEntries(
1707                                    MBDiscussion.class, message.getPrimaryKey(),
1708                                    messagePKs.get(message.getPrimaryKey()));
1709                    }
1710            }
1711    
1712            @Override
1713            public void importLocks(Class<?> clazz, String key, String newKey)
1714                    throws PortalException, SystemException {
1715    
1716                    Lock lock = _locksMap.get(getPrimaryKeyString(clazz, key));
1717    
1718                    if (lock == null) {
1719                            return;
1720                    }
1721    
1722                    long userId = getUserId(lock.getUserUuid());
1723    
1724                    long expirationTime = 0;
1725    
1726                    if (lock.getExpirationDate() != null) {
1727                            Date expirationDate = lock.getExpirationDate();
1728    
1729                            expirationTime = expirationDate.getTime();
1730                    }
1731    
1732                    LockLocalServiceUtil.lock(
1733                            userId, clazz.getName(), newKey, lock.getOwner(),
1734                            lock.isInheritable(), expirationTime);
1735            }
1736    
1737            @Override
1738            public void importPermissions(Class<?> clazz, long classPK, long newClassPK)
1739                    throws PortalException, SystemException {
1740    
1741                    importPermissions(clazz.getName(), classPK, newClassPK);
1742            }
1743    
1744            @Override
1745            public void importPermissions(
1746                            String resourceName, long resourcePK, long newResourcePK)
1747                    throws PortalException, SystemException {
1748    
1749                    if (!MapUtil.getBoolean(
1750                                    _parameterMap, PortletDataHandlerKeys.PERMISSIONS)) {
1751    
1752                            return;
1753                    }
1754    
1755                    List<KeyValuePair> permissions = _permissionsMap.get(
1756                            getPrimaryKeyString(resourceName, resourcePK));
1757    
1758                    if (permissions == null) {
1759                            return;
1760                    }
1761    
1762                    Map<Long, String[]> roleIdsToActionIds = new HashMap<Long, String[]>();
1763    
1764                    for (KeyValuePair permission : permissions) {
1765                            String roleName = permission.getKey();
1766    
1767                            Role role = null;
1768    
1769                            Team team = null;
1770    
1771                            if (roleName.startsWith(PermissionExporter.ROLE_TEAM_PREFIX)) {
1772                                    roleName = roleName.substring(
1773                                            PermissionExporter.ROLE_TEAM_PREFIX.length());
1774    
1775                                    try {
1776                                            team = TeamLocalServiceUtil.getTeam(_groupId, roleName);
1777                                    }
1778                                    catch (NoSuchTeamException nste) {
1779                                            if (_log.isWarnEnabled()) {
1780                                                    _log.warn("Team " + roleName + " does not exist");
1781                                            }
1782    
1783                                            continue;
1784                                    }
1785                            }
1786    
1787                            try {
1788                                    if (team != null) {
1789                                            role = RoleLocalServiceUtil.getTeamRole(
1790                                                    _companyId, team.getTeamId());
1791                                    }
1792                                    else {
1793                                            role = RoleLocalServiceUtil.getRole(_companyId, roleName);
1794                                    }
1795                            }
1796                            catch (NoSuchRoleException nsre) {
1797                                    if (_log.isWarnEnabled()) {
1798                                            _log.warn("Role " + roleName + " does not exist");
1799                                    }
1800    
1801                                    continue;
1802                            }
1803    
1804                            if (isPrivateLayout() &&
1805                                    resourceName.equals(Layout.class.getName()) &&
1806                                    roleName.equals(RoleConstants.GUEST)) {
1807    
1808                                    continue;
1809                            }
1810    
1811                            String[] actionIds = StringUtil.split(permission.getValue());
1812    
1813                            roleIdsToActionIds.put(role.getRoleId(), actionIds);
1814                    }
1815    
1816                    if (roleIdsToActionIds.isEmpty()) {
1817                            return;
1818                    }
1819    
1820                    if (ResourceBlockLocalServiceUtil.isSupported(resourceName)) {
1821                            ResourceBlockLocalServiceUtil.setIndividualScopePermissions(
1822                                    _companyId, _groupId, resourceName, newResourcePK,
1823                                    roleIdsToActionIds);
1824                    }
1825                    else {
1826                            ResourcePermissionLocalServiceUtil.setResourcePermissions(
1827                                    _companyId, resourceName, ResourceConstants.SCOPE_INDIVIDUAL,
1828                                    String.valueOf(newResourcePK), roleIdsToActionIds);
1829                    }
1830            }
1831    
1832            @Override
1833            public void importPortalPermissions()
1834                    throws PortalException, SystemException {
1835    
1836                    importPermissions(
1837                            PortletKeys.PORTAL, getSourceCompanyId(), getCompanyId());
1838            }
1839    
1840            @Override
1841            public void importPortletPermissions(String resourceName)
1842                    throws PortalException, SystemException {
1843    
1844                    importPermissions(resourceName, getSourceGroupId(), getScopeGroupId());
1845            }
1846    
1847            @Override
1848            public void importRatingsEntries(
1849                            Class<?> clazz, long classPK, long newClassPK)
1850                    throws PortalException, SystemException {
1851    
1852                    List<RatingsEntry> ratingsEntries = _ratingsEntriesMap.get(
1853                            getPrimaryKeyString(clazz, classPK));
1854    
1855                    if ((ratingsEntries == null) || ratingsEntries.isEmpty()) {
1856                            return;
1857                    }
1858    
1859                    ServiceContext serviceContext = new ServiceContext();
1860    
1861                    for (RatingsEntry ratingsEntry : ratingsEntries) {
1862                            long userId = getUserId(ratingsEntry.getUserUuid());
1863    
1864                            serviceContext.setCreateDate(ratingsEntry.getCreateDate());
1865                            serviceContext.setModifiedDate(ratingsEntry.getModifiedDate());
1866    
1867                            RatingsEntryLocalServiceUtil.updateEntry(
1868                                    userId, clazz.getName(), newClassPK, ratingsEntry.getScore(),
1869                                    serviceContext);
1870                    }
1871            }
1872    
1873            @Override
1874            public boolean isCompanyStagedGroupedModel(
1875                    StagedGroupedModel stagedGroupedModel) {
1876    
1877                    if ((stagedGroupedModel.getGroupId() == getCompanyGroupId()) &&
1878                            (getGroupId() != getCompanyGroupId())) {
1879    
1880                            return true;
1881                    }
1882    
1883                    return false;
1884            }
1885    
1886            @Override
1887            public boolean isDataStrategyMirror() {
1888                    if (_dataStrategy.equals(PortletDataHandlerKeys.DATA_STRATEGY_MIRROR) ||
1889                            _dataStrategy.equals(
1890                                    PortletDataHandlerKeys.DATA_STRATEGY_MIRROR_OVERWRITE)) {
1891    
1892                            return true;
1893                    }
1894                    else {
1895                            return false;
1896                    }
1897            }
1898    
1899            @Override
1900            public boolean isDataStrategyMirrorWithOverwriting() {
1901                    if (_dataStrategy.equals(
1902                                    PortletDataHandlerKeys.DATA_STRATEGY_MIRROR_OVERWRITE)) {
1903    
1904                            return true;
1905                    }
1906                    else {
1907                            return false;
1908                    }
1909            }
1910    
1911            @Override
1912            public boolean isInitialPublication() {
1913                    Group group = null;
1914    
1915                    try {
1916                            group = GroupLocalServiceUtil.getGroup(getGroupId());
1917                    }
1918                    catch (Exception e) {
1919                    }
1920    
1921                    if (ExportImportThreadLocal.isStagingInProcess() && (group != null) &&
1922                            group.hasStagingGroup()) {
1923    
1924                            return true;
1925                    }
1926    
1927                    return false;
1928            }
1929    
1930            @Override
1931            public boolean isMissingReference(Element referenceElement) {
1932                    Attribute missingAttribute = referenceElement.attribute("missing");
1933    
1934                    if ((missingAttribute != null) &&
1935                            !GetterUtil.getBoolean(
1936                                    referenceElement.attributeValue("missing"))) {
1937    
1938                            return false;
1939                    }
1940    
1941                    if (_missingReferences.isEmpty()) {
1942                            List<Element> missingReferenceElements =
1943                                    _missingReferencesElement.elements();
1944    
1945                            for (Element missingReferenceElement : missingReferenceElements) {
1946                                    String missingReferenceClassName =
1947                                            missingReferenceElement.attributeValue("class-name");
1948                                    String missingReferenceClassPK =
1949                                            missingReferenceElement.attributeValue("class-pk");
1950    
1951                                    String missingReferenceKey = getReferenceKey(
1952                                            missingReferenceClassName, missingReferenceClassPK);
1953    
1954                                    _missingReferences.add(missingReferenceKey);
1955                            }
1956                    }
1957    
1958                    String className = referenceElement.attributeValue("class-name");
1959                    String classPK = referenceElement.attributeValue("class-pk");
1960    
1961                    String referenceKey = getReferenceKey(className, classPK);
1962    
1963                    return _missingReferences.contains(referenceKey);
1964            }
1965    
1966            @Override
1967            public boolean isModelCounted(String className, long classPK) {
1968                    String modelCountedPrimaryKey = className.concat(
1969                            StringPool.POUND).concat(String.valueOf(classPK));
1970    
1971                    return addPrimaryKey(String.class, modelCountedPrimaryKey);
1972            }
1973    
1974            @Override
1975            public boolean isPathExportedInScope(String path) {
1976                    return addScopedPrimaryKey(String.class, path);
1977            }
1978    
1979            /**
1980             * @deprecated As of 7.0.0
1981             */
1982            @Deprecated
1983            @Override
1984            public boolean isPathNotExportedInScope(String path) {
1985                    return !isPathExportedInScope(path);
1986            }
1987    
1988            @Override
1989            public boolean isPathNotProcessed(String path) {
1990                    return !isPathProcessed(path);
1991            }
1992    
1993            @Override
1994            public boolean isPathProcessed(String path) {
1995                    addScopedPrimaryKey(String.class, path);
1996    
1997                    return addPrimaryKey(String.class, path);
1998            }
1999    
2000            @Override
2001            public boolean isPerformDirectBinaryImport() {
2002                    return MapUtil.getBoolean(
2003                            _parameterMap, PortletDataHandlerKeys.PERFORM_DIRECT_BINARY_IMPORT);
2004            }
2005    
2006            @Override
2007            public boolean isPrivateLayout() {
2008                    return _privateLayout;
2009            }
2010    
2011            @Override
2012            public boolean isStagedModelCounted(StagedModel stagedModel) {
2013                    StagedModelType stagedModelType = stagedModel.getStagedModelType();
2014    
2015                    return isModelCounted(
2016                            stagedModelType.getClassName(),
2017                            (Long)stagedModel.getPrimaryKeyObj());
2018            }
2019    
2020            /**
2021             * @see #addDateRangeCriteria(DynamicQuery, String)
2022             */
2023            @Override
2024            public boolean isWithinDateRange(Date modifiedDate) {
2025                    if (!hasDateRange()) {
2026                            return true;
2027                    }
2028                    else if ((_startDate.compareTo(modifiedDate) <= 0) &&
2029                                     _endDate.after(modifiedDate)) {
2030    
2031                            return true;
2032                    }
2033                    else {
2034                            return false;
2035                    }
2036            }
2037    
2038            @Override
2039            public void putNotUniquePerLayout(String dataKey) {
2040                    _notUniquePerLayout.add(dataKey);
2041            }
2042    
2043            @Override
2044            public void setClassLoader(ClassLoader classLoader) {
2045                    _xStream.setClassLoader(classLoader);
2046            }
2047    
2048            @Override
2049            public void setCompanyGroupId(long companyGroupId) {
2050                    _companyGroupId = companyGroupId;
2051            }
2052    
2053            @Override
2054            public void setCompanyId(long companyId) {
2055                    _companyId = companyId;
2056            }
2057    
2058            @Override
2059            public void setDataStrategy(String dataStrategy) {
2060                    _dataStrategy = dataStrategy;
2061            }
2062    
2063            @Override
2064            public void setEndDate(Date endDate) {
2065                    _endDate = endDate;
2066            }
2067    
2068            @Override
2069            public void setExportDataRootElement(Element exportDataRootElement) {
2070                    _exportDataRootElement = exportDataRootElement;
2071            }
2072    
2073            @Override
2074            public void setGroupId(long groupId) {
2075                    _groupId = groupId;
2076            }
2077    
2078            @Override
2079            public void setImportDataRootElement(Element importDataRootElement) {
2080                    _importDataRootElement = importDataRootElement;
2081            }
2082    
2083            @Override
2084            public void setManifestSummary(ManifestSummary manifestSummary) {
2085                    _manifestSummary = manifestSummary;
2086            }
2087    
2088            @Override
2089            public void setMissingReferencesElement(Element missingReferencesElement) {
2090                    _missingReferencesElement = missingReferencesElement;
2091            }
2092    
2093            @Override
2094            public void setNewLayouts(List<Layout> newLayouts) {
2095                    _newLayouts = newLayouts;
2096            }
2097    
2098            @Override
2099            public void setNewPrimaryKeysMaps(
2100                    Map<String, Map<?, ?>> newPrimaryKeysMaps) {
2101    
2102                    _newPrimaryKeysMaps = newPrimaryKeysMaps;
2103            }
2104    
2105            @Override
2106            public void setOldPlid(long oldPlid) {
2107                    _oldPlid = oldPlid;
2108            }
2109    
2110            @Override
2111            public void setParameterMap(Map<String, String[]> parameterMap) {
2112                    _parameterMap = parameterMap;
2113            }
2114    
2115            @Override
2116            public void setPlid(long plid) {
2117                    _plid = plid;
2118            }
2119    
2120            @Override
2121            public void setPortetDataContextListener(
2122                    PortletDataContextListener portletDataContextListener) {
2123    
2124                    _portletDataContextListener = portletDataContextListener;
2125            }
2126    
2127            @Override
2128            public void setPrivateLayout(boolean privateLayout) {
2129                    _privateLayout = privateLayout;
2130            }
2131    
2132            @Override
2133            public void setRootPortletId(String rootPortletId) {
2134                    _rootPortletId = rootPortletId;
2135            }
2136    
2137            @Override
2138            public void setScopeGroupId(long scopeGroupId) {
2139                    _scopeGroupId = scopeGroupId;
2140            }
2141    
2142            @Override
2143            public void setScopeLayoutUuid(String scopeLayoutUuid) {
2144                    _scopeLayoutUuid = scopeLayoutUuid;
2145            }
2146    
2147            @Override
2148            public void setScopeType(String scopeType) {
2149                    _scopeType = scopeType;
2150            }
2151    
2152            @Override
2153            public void setSourceCompanyGroupId(long sourceCompanyGroupId) {
2154                    _sourceCompanyGroupId = sourceCompanyGroupId;
2155            }
2156    
2157            @Override
2158            public void setSourceCompanyId(long sourceCompanyId) {
2159                    _sourceCompanyId = sourceCompanyId;
2160            }
2161    
2162            @Override
2163            public void setSourceGroupId(long sourceGroupId) {
2164                    _sourceGroupId = sourceGroupId;
2165            }
2166    
2167            @Override
2168            public void setSourceUserPersonalSiteGroupId(
2169                    long sourceUserPersonalSiteGroupId) {
2170    
2171                    _sourceUserPersonalSiteGroupId = sourceUserPersonalSiteGroupId;
2172            }
2173    
2174            @Override
2175            public void setStartDate(Date startDate) {
2176                    _startDate = startDate;
2177            }
2178    
2179            @Override
2180            public void setUserIdStrategy(UserIdStrategy userIdStrategy) {
2181                    _userIdStrategy = userIdStrategy;
2182            }
2183    
2184            @Override
2185            public void setUserPersonalSiteGroupId(long userPersonalSiteGroupId) {
2186                    _userPersonalSiteGroupId = userPersonalSiteGroupId;
2187            }
2188    
2189            @Override
2190            public void setZipReader(ZipReader zipReader) {
2191                    _zipReader = zipReader;
2192            }
2193    
2194            @Override
2195            public void setZipWriter(ZipWriter zipWriter) {
2196                    _zipWriter = zipWriter;
2197            }
2198    
2199            @Override
2200            public String toXML(Object object) {
2201                    return _xStream.toXML(object);
2202            }
2203    
2204            protected void addExpando(
2205                            Element element, String path, ClassedModel classedModel,
2206                            Class<?> clazz)
2207                    throws PortalException, SystemException {
2208    
2209                    String className = clazz.getName();
2210    
2211                    if (!_expandoColumnsMap.containsKey(className)) {
2212                            List<ExpandoColumn> expandoColumns =
2213                                    ExpandoColumnLocalServiceUtil.getDefaultTableColumns(
2214                                            _companyId, className);
2215    
2216                            for (ExpandoColumn expandoColumn : expandoColumns) {
2217                                    addPermissions(
2218                                            ExpandoColumn.class, expandoColumn.getColumnId());
2219                            }
2220    
2221                            _expandoColumnsMap.put(className, expandoColumns);
2222                    }
2223    
2224                    ExpandoBridge expandoBridge = classedModel.getExpandoBridge();
2225    
2226                    Map<String, Serializable> expandoBridgeAttributes =
2227                            expandoBridge.getAttributes();
2228    
2229                    if (!expandoBridgeAttributes.isEmpty()) {
2230                            String expandoPath = ExportImportPathUtil.getExpandoPath(path);
2231    
2232                            element.addAttribute("expando-path", expandoPath);
2233    
2234                            addZipEntry(expandoPath, expandoBridgeAttributes);
2235                    }
2236            }
2237    
2238            protected ServiceContext createServiceContext(
2239                    Element element, String path, ClassedModel classedModel,
2240                    Class<?> clazz) {
2241    
2242                    long classPK = getClassPK(classedModel);
2243    
2244                    ServiceContext serviceContext = new ServiceContext();
2245    
2246                    // Theme display
2247    
2248                    serviceContext.setCompanyId(getCompanyId());
2249                    serviceContext.setScopeGroupId(getScopeGroupId());
2250    
2251                    // Dates
2252    
2253                    if (classedModel instanceof AuditedModel) {
2254                            AuditedModel auditedModel = (AuditedModel)classedModel;
2255    
2256                            serviceContext.setUserId(getUserId(auditedModel));
2257                            serviceContext.setCreateDate(auditedModel.getCreateDate());
2258                            serviceContext.setModifiedDate(auditedModel.getModifiedDate());
2259                    }
2260    
2261                    // Permissions
2262    
2263                    if (!MapUtil.getBoolean(
2264                                    _parameterMap, PortletDataHandlerKeys.PERMISSIONS)) {
2265    
2266                            serviceContext.setAddGroupPermissions(true);
2267                            serviceContext.setAddGuestPermissions(true);
2268                    }
2269    
2270                    // Asset
2271    
2272                    if (isResourceMain(classedModel)) {
2273                            long[] assetCategoryIds = getAssetCategoryIds(clazz, classPK);
2274    
2275                            serviceContext.setAssetCategoryIds(assetCategoryIds);
2276    
2277                            String[] assetTagNames = getAssetTagNames(clazz, classPK);
2278    
2279                            serviceContext.setAssetTagNames(assetTagNames);
2280    
2281                            if (ExportImportThreadLocal.isStagingInProcess()) {
2282                                    serviceContext.setAssetLinkEntryIds(new long[0]);
2283                            }
2284                    }
2285    
2286                    // Expando
2287    
2288                    String expandoPath = null;
2289    
2290                    if (element != null) {
2291                            expandoPath = element.attributeValue("expando-path");
2292                    }
2293                    else {
2294                            expandoPath = ExportImportPathUtil.getExpandoPath(path);
2295                    }
2296    
2297                    if (Validator.isNotNull(expandoPath)) {
2298                            try {
2299                                    Map<String, Serializable> expandoBridgeAttributes =
2300                                            (Map<String, Serializable>)getZipEntryAsObject(expandoPath);
2301    
2302                                    if (expandoBridgeAttributes != null) {
2303                                            serviceContext.setExpandoBridgeAttributes(
2304                                                    expandoBridgeAttributes);
2305                                    }
2306                            }
2307                            catch (Exception e) {
2308                                    if (_log.isDebugEnabled()) {
2309                                            _log.debug(e, e);
2310                                    }
2311                            }
2312                    }
2313    
2314                    return serviceContext;
2315            }
2316    
2317            protected Element doAddReferenceElement(
2318                    ClassedModel referrerClassedModel, Element element,
2319                    ClassedModel classedModel, String className, String binPath,
2320                    String referenceType, boolean missing) {
2321    
2322                    Element referenceElement = null;
2323    
2324                    if (missing) {
2325                            Element referencesElement = _missingReferencesElement;
2326    
2327                            referenceElement = referencesElement.addElement(
2328                                    "missing-reference");
2329                    }
2330                    else {
2331                            Element referencesElement = element.element("references");
2332    
2333                            if (referencesElement == null) {
2334                                    referencesElement = element.addElement("references");
2335                            }
2336    
2337                            referenceElement = referencesElement.addElement("reference");
2338                    }
2339    
2340                    referenceElement.addAttribute("class-name", className);
2341    
2342                    referenceElement.addAttribute(
2343                            "class-pk", String.valueOf(classedModel.getPrimaryKeyObj()));
2344    
2345                    if (missing) {
2346                            if (classedModel instanceof StagedModel) {
2347                                    referenceElement.addAttribute(
2348                                            "display-name",
2349                                            StagedModelDataHandlerUtil.getDisplayName(
2350                                                    (StagedModel)classedModel));
2351                            }
2352                            else {
2353                                    referenceElement.addAttribute(
2354                                            "display-name",
2355                                            String.valueOf(classedModel.getPrimaryKeyObj()));
2356                            }
2357                    }
2358    
2359                    if (classedModel instanceof StagedGroupedModel) {
2360                            StagedGroupedModel stagedGroupedModel =
2361                                    (StagedGroupedModel)classedModel;
2362    
2363                            referenceElement.addAttribute(
2364                                    "group-id", String.valueOf(stagedGroupedModel.getGroupId()));
2365                    }
2366    
2367                    if (Validator.isNotNull(binPath)) {
2368                            referenceElement.addAttribute("path", binPath);
2369                    }
2370    
2371                    referenceElement.addAttribute("type", referenceType);
2372    
2373                    if (missing) {
2374                            referenceElement.addAttribute(
2375                                    "referrer-class-name",
2376                                    ExportImportClassedModelUtil.getClassName(
2377                                            referrerClassedModel));
2378    
2379                            if (referrerClassedModel instanceof PortletModel) {
2380                                    Portlet portlet = (Portlet)referrerClassedModel;
2381    
2382                                    referenceElement.addAttribute(
2383                                            "referrer-display-name", portlet.getRootPortletId());
2384                            }
2385                            else if (referrerClassedModel instanceof StagedModel) {
2386                                    StagedModel referrerStagedModel =
2387                                            (StagedModel)referrerClassedModel;
2388    
2389                                    referenceElement.addAttribute(
2390                                            "referrer-display-name",
2391                                            StagedModelDataHandlerUtil.getDisplayName(
2392                                                    referrerStagedModel));
2393                            }
2394                    }
2395    
2396                    if (classedModel instanceof StagedModel) {
2397                            StagedModel stagedModel = (StagedModel)classedModel;
2398    
2399                            referenceElement.addAttribute("uuid", stagedModel.getUuid());
2400                            referenceElement.addAttribute(
2401                                    "company-id", String.valueOf(stagedModel.getCompanyId()));
2402    
2403                            Map<String, String> referenceAttributes =
2404                                    StagedModelDataHandlerUtil.getReferenceAttributes(
2405                                            this, stagedModel);
2406    
2407                            for (Map.Entry<String, String> referenceAttribute :
2408                                            referenceAttributes.entrySet()) {
2409    
2410                                    referenceElement.addAttribute(
2411                                            referenceAttribute.getKey(), referenceAttribute.getValue());
2412                            }
2413                    }
2414    
2415                    return referenceElement;
2416            }
2417    
2418            protected Map<Long, Set<String>> getActionIds(
2419                            long companyId, long[] roleIds, String className, long primKey,
2420                            List<String> actionIds)
2421                    throws PortalException, SystemException {
2422    
2423                    if (ResourceBlockLocalServiceUtil.isSupported(className)) {
2424                            return ResourceBlockPermissionLocalServiceUtil.
2425                                    getAvailableResourceBlockPermissionActionIds(
2426                                            roleIds, className, primKey, actionIds);
2427                    }
2428                    else {
2429                            return ResourcePermissionLocalServiceUtil.
2430                                    getAvailableResourcePermissionActionIds(
2431                                            companyId, className, ResourceConstants.SCOPE_INDIVIDUAL,
2432                                            String.valueOf(primKey), roleIds, actionIds);
2433                    }
2434            }
2435    
2436            protected long getClassPK(ClassedModel classedModel) {
2437                    if (classedModel instanceof ResourcedModel) {
2438                            ResourcedModel resourcedModel = (ResourcedModel)classedModel;
2439    
2440                            return resourcedModel.getResourcePrimKey();
2441                    }
2442                    else {
2443                            return (Long)classedModel.getPrimaryKeyObj();
2444                    }
2445            }
2446    
2447            protected Element getDataElement(
2448                    Element parentElement, String attribute, String value) {
2449    
2450                    if (parentElement == null) {
2451                            return null;
2452                    }
2453    
2454                    StringBundler sb = new StringBundler(6);
2455    
2456                    sb.append("staged-model");
2457                    sb.append("[@");
2458                    sb.append(attribute);
2459                    sb.append(StringPool.EQUAL);
2460                    sb.append(HtmlUtil.escapeXPathAttribute(value));
2461                    sb.append(StringPool.CLOSE_BRACKET);
2462    
2463                    XPath xPath = SAXReaderUtil.createXPath(sb.toString());
2464    
2465                    return (Element)xPath.selectSingleNode(parentElement);
2466            }
2467    
2468            protected String getExpandoPath(String path) {
2469                    return ExportImportPathUtil.getExpandoPath(path);
2470            }
2471    
2472            protected Element getExportDataGroupElement(String name) {
2473                    if (_exportDataRootElement == null) {
2474                            throw new IllegalStateException(
2475                                    "Root data element not initialized");
2476                    }
2477    
2478                    Element groupElement = _exportDataRootElement.element(name);
2479    
2480                    if (groupElement == null) {
2481                            groupElement = _exportDataRootElement.addElement(name);
2482                    }
2483    
2484                    return groupElement;
2485            }
2486    
2487            protected Element getImportDataGroupElement(String name) {
2488                    if (_importDataRootElement == null) {
2489                            throw new IllegalStateException(
2490                                    "Root data element not initialized");
2491                    }
2492    
2493                    if (Validator.isNull(name)) {
2494                            return SAXReaderUtil.createElement("EMPTY-ELEMENT");
2495                    }
2496    
2497                    Element groupElement = _importDataRootElement.element(name);
2498    
2499                    if (groupElement == null) {
2500                            return SAXReaderUtil.createElement("EMPTY-ELEMENT");
2501                    }
2502    
2503                    return groupElement;
2504            }
2505    
2506            protected Element getMissingReferenceElement(ClassedModel classedModel) {
2507                    StringBundler sb = new StringBundler(5);
2508    
2509                    sb.append("missing-reference[@class-name='");
2510                    sb.append(ExportImportClassedModelUtil.getClassName(classedModel));
2511                    sb.append("' and @class-pk='");
2512                    sb.append(String.valueOf(classedModel.getPrimaryKeyObj()));
2513                    sb.append("']");
2514    
2515                    XPath xPath = SAXReaderUtil.createXPath(sb.toString());
2516    
2517                    Node node = xPath.selectSingleNode(_missingReferencesElement);
2518    
2519                    return (Element)node;
2520            }
2521    
2522            protected String getPrimaryKeyString(Class<?> clazz, long classPK) {
2523                    return getPrimaryKeyString(clazz.getName(), String.valueOf(classPK));
2524            }
2525    
2526            protected String getPrimaryKeyString(Class<?> clazz, String primaryKey) {
2527                    return getPrimaryKeyString(clazz.getName(), primaryKey);
2528            }
2529    
2530            protected String getPrimaryKeyString(String className, long classPK) {
2531                    return getPrimaryKeyString(className, String.valueOf(classPK));
2532            }
2533    
2534            protected String getPrimaryKeyString(String className, String primaryKey) {
2535                    return className.concat(StringPool.POUND).concat(primaryKey);
2536            }
2537    
2538            protected List<Element> getReferenceDataElements(
2539                    List<Element> referenceElements, Class<?> clazz) {
2540    
2541                    List<Element> referenceDataElements = new ArrayList<Element>();
2542    
2543                    for (Element referenceElement : referenceElements) {
2544                            Element referenceDataElement = null;
2545    
2546                            String path = referenceElement.attributeValue("path");
2547    
2548                            if (Validator.isNotNull(path)) {
2549                                    referenceDataElement = getImportDataElement(
2550                                            clazz.getSimpleName(), "path", path);
2551                            }
2552                            else {
2553                                    String groupId = referenceElement.attributeValue("group-id");
2554                                    String uuid = referenceElement.attributeValue("uuid");
2555    
2556                                    StringBuilder sb = new StringBuilder(5);
2557    
2558                                    sb.append("staged-model[@uuid=");
2559                                    sb.append(HtmlUtil.escapeXPathAttribute(uuid));
2560    
2561                                    if (groupId != null) {
2562                                            sb.append(" and @group-id=");
2563                                            sb.append(HtmlUtil.escapeXPathAttribute(groupId));
2564                                    }
2565    
2566                                    sb.append(StringPool.CLOSE_BRACKET);
2567    
2568                                    XPath xPath = SAXReaderUtil.createXPath(sb.toString());
2569    
2570                                    Element groupElement = getImportDataGroupElement(
2571                                            clazz.getSimpleName());
2572    
2573                                    referenceDataElement = (Element)xPath.selectSingleNode(
2574                                            groupElement);
2575                            }
2576    
2577                            if (referenceDataElement == null) {
2578                                    continue;
2579                            }
2580    
2581                            referenceDataElements.add(referenceDataElement);
2582                    }
2583    
2584                    return referenceDataElements;
2585            }
2586    
2587            protected List<Element> getReferenceElements(
2588                    Element parentElement, Class<?> clazz, long groupId, String uuid,
2589                    long classPK, String referenceType) {
2590    
2591                    if (parentElement == null) {
2592                            return Collections.emptyList();
2593                    }
2594    
2595                    Element referencesElement = parentElement.element("references");
2596    
2597                    if (referencesElement == null) {
2598                            return Collections.emptyList();
2599                    }
2600    
2601                    StringBundler sb = new StringBundler(13);
2602    
2603                    sb.append("reference[@class-name=");
2604                    sb.append(HtmlUtil.escapeXPathAttribute(clazz.getName()));
2605    
2606                    if (groupId > 0) {
2607                            sb.append(" and @group-id='");
2608                            sb.append(groupId);
2609                            sb.append(StringPool.APOSTROPHE);
2610                    }
2611    
2612                    if (Validator.isNotNull(uuid)) {
2613                            sb.append(" and @uuid=");
2614                            sb.append(HtmlUtil.escapeXPathAttribute(uuid));
2615                    }
2616    
2617                    if (classPK > 0) {
2618                            sb.append(" and @class-pk='");
2619                            sb.append(classPK);
2620                            sb.append(StringPool.APOSTROPHE);
2621                    }
2622    
2623                    if (referenceType != null) {
2624                            sb.append(" and @type=");
2625                            sb.append(HtmlUtil.escapeXPathAttribute(referenceType));
2626                    }
2627    
2628                    sb.append(StringPool.CLOSE_BRACKET);
2629    
2630                    XPath xPath = SAXReaderUtil.createXPath(sb.toString());
2631    
2632                    List<Node> nodes = xPath.selectNodes(referencesElement);
2633    
2634                    return ListUtil.fromArray(nodes.toArray(new Element[nodes.size()]));
2635            }
2636    
2637            protected List<Element> getReferenceElements(
2638                    StagedModel parentStagedModel, Class<?> clazz, long classPK,
2639                    String referenceType) {
2640    
2641                    Element stagedModelElement = getImportDataStagedModelElement(
2642                            parentStagedModel);
2643    
2644                    return getReferenceElements(
2645                            stagedModelElement, clazz, 0, null, classPK, referenceType);
2646            }
2647    
2648            protected String getReferenceKey(ClassedModel classedModel) {
2649                    return getReferenceKey(
2650                            ExportImportClassedModelUtil.getClassName(classedModel),
2651                            String.valueOf(classedModel.getPrimaryKeyObj()));
2652            }
2653    
2654            protected String getReferenceKey(String className, String classPK) {
2655                    return className.concat(StringPool.POUND).concat(classPK);
2656            }
2657    
2658            protected long getUserId(AuditedModel auditedModel) {
2659                    try {
2660                            String userUuid = auditedModel.getUserUuid();
2661    
2662                            return getUserId(userUuid);
2663                    }
2664                    catch (SystemException se) {
2665                            if (_log.isErrorEnabled()) {
2666                                    _log.error(se, se);
2667                            }
2668                    }
2669    
2670                    return 0;
2671            }
2672    
2673            protected void initXStream() {
2674                    _xStream = new XStream();
2675    
2676                    // Aliases
2677    
2678                    _xStream.alias("BlogsEntry", BlogsEntryImpl.class);
2679                    _xStream.alias("BookmarksFolder", BookmarksFolderImpl.class);
2680                    _xStream.alias("BookmarksEntry", BookmarksEntryImpl.class);
2681                    _xStream.alias("DLFolder", DLFolderImpl.class);
2682                    _xStream.alias("DLFileEntry", DLFileEntryImpl.class);
2683                    _xStream.alias("DLFileShortcut", DLFileShortcutImpl.class);
2684                    _xStream.alias("JournalArticle", JournalArticleImpl.class);
2685                    _xStream.alias("JournalFeed", JournalFeedImpl.class);
2686                    _xStream.alias("Lock", LockImpl.class);
2687                    _xStream.alias("MBBan", MBBanImpl.class);
2688                    _xStream.alias("MBCategory", MBCategoryImpl.class);
2689                    _xStream.alias("MBMessage", MBMessageImpl.class);
2690                    _xStream.alias("MBThreadFlag", MBThreadFlagImpl.class);
2691                    _xStream.alias("PollsQuestion", PollsQuestionImpl.class);
2692                    _xStream.alias("PollsChoice", PollsChoiceImpl.class);
2693                    _xStream.alias("PollsVote", PollsVoteImpl.class);
2694                    _xStream.alias("RatingsEntry", RatingsEntryImpl.class);
2695                    _xStream.alias("WikiNode", WikiNodeImpl.class);
2696                    _xStream.alias("WikiPage", WikiPageImpl.class);
2697    
2698                    // Omit fields
2699    
2700                    _xStream.omitField(HashMap.class, "cache_bitmask");
2701    
2702                    // Register converters
2703    
2704                    _xStream.registerConverter(
2705                            new FolderConverter(), XStream.PRIORITY_VERY_HIGH);
2706                    _xStream.registerConverter(
2707                            new FileEntryConverter(), XStream.PRIORITY_VERY_HIGH);
2708                    _xStream.registerConverter(
2709                            new FileVersionConverter(), XStream.PRIORITY_VERY_HIGH);
2710    
2711                    if (!PropsValues.STAGING_XSTREAM_SECURITY_ENABLED) {
2712                            return;
2713                    }
2714    
2715                    // Permissions
2716    
2717                    // Wipe all of them
2718    
2719                    _xStream.addPermission(NoTypePermission.NONE);
2720    
2721                    // Add permissions
2722    
2723                    _xStream.addPermission(PrimitiveTypePermission.PRIMITIVES);
2724    
2725                    List<String> allowedTypes = new ArrayList<String>();
2726    
2727                    allowedTypes.addAll(
2728                            ListUtil.toList(_XSTREAM_DEFAULT_ALLOWED_CLASS_NAMES));
2729                    allowedTypes.addAll(
2730                            ListUtil.toList(PropsValues.STAGING_XSTREAM_CLASS_WHITELIST));
2731    
2732                    _xStream.allowTypes(allowedTypes.toArray(new String[0]));
2733    
2734                    _xStream.allowTypeHierarchy(AssetLink.class);
2735                    _xStream.allowTypeHierarchy(AssetTag.class);
2736                    _xStream.allowTypeHierarchy(List.class);
2737                    _xStream.allowTypeHierarchy(Lock.class);
2738                    _xStream.allowTypeHierarchy(Map.class);
2739                    _xStream.allowTypeHierarchy(OrgLabor.class);
2740                    _xStream.allowTypeHierarchy(RatingsEntry.class);
2741                    _xStream.allowTypeHierarchy(StagedModel.class);
2742    
2743                    _xStream.allowTypesByWildcard(
2744                            new String[] {
2745                                    "com.liferay.portal.model.*", "com.liferay.portal.model.impl.*",
2746                                    "com.thoughtworks.xstream.mapper.DynamicProxyMapper*"
2747                            }
2748                    );
2749            }
2750    
2751            protected boolean isResourceMain(ClassedModel classedModel) {
2752                    if (classedModel instanceof ResourcedModel) {
2753                            ResourcedModel resourcedModel = (ResourcedModel)classedModel;
2754    
2755                            return resourcedModel.isResourceMain();
2756                    }
2757    
2758                    return true;
2759            }
2760    
2761            protected void updateAssetCategoriesPrimaryKeyString(
2762                    Class<?> clazz, ClassedModel classedModel) {
2763    
2764                    long classPK = getClassPK(classedModel);
2765    
2766                    String primaryKeyString = getPrimaryKeyString(clazz, classPK);
2767    
2768                    long primaryKey = (Long)classedModel.getPrimaryKeyObj();
2769    
2770                    String updatedPrimaryKeyString = getPrimaryKeyString(
2771                            primaryKeyString, primaryKey);
2772    
2773                    String[] uuids = _assetCategoryUuidsMap.remove(primaryKeyString);
2774    
2775                    _assetCategoryUuidsMap.put(updatedPrimaryKeyString, uuids);
2776            }
2777    
2778            private static final String[] _XSTREAM_DEFAULT_ALLOWED_CLASS_NAMES =
2779                    new String[] {
2780                            BigDecimal.class.getName(), byte[].class.getName(),
2781                            Date.class.getName(), Field.class.getName(), Fields.class.getName(),
2782                            InputStream.class.getName(), Locale.class.getName(),
2783                            String.class.getName(), String[].class.getName(),
2784                            Time.class.getName(), Timestamp.class.getName()
2785                    };
2786    
2787            private static Log _log = LogFactoryUtil.getLog(
2788                    PortletDataContextImpl.class);
2789    
2790            private Map<String, long[]> _assetCategoryIdsMap =
2791                    new HashMap<String, long[]>();
2792            private Map<String, String[]> _assetCategoryUuidsMap =
2793                    new HashMap<String, String[]>();
2794            private Map<String, List<AssetLink>> _assetLinksMap =
2795                    new HashMap<String, List<AssetLink>>();
2796            private Map<String, String[]> _assetTagNamesMap =
2797                    new HashMap<String, String[]>();
2798            private Map<String, List<MBMessage>> _commentsMap =
2799                    new HashMap<String, List<MBMessage>>();
2800            private long _companyGroupId;
2801            private long _companyId;
2802            private String _dataStrategy;
2803            private Set<StagedModelType> _deletionSystemEventModelTypes =
2804                    new HashSet<StagedModelType>();
2805            private Date _endDate;
2806            private Map<String, List<ExpandoColumn>> _expandoColumnsMap =
2807                    new HashMap<String, List<ExpandoColumn>>();
2808            private transient Element _exportDataRootElement;
2809            private long _groupId;
2810            private transient Element _importDataRootElement;
2811            private transient Map<String, Lock> _locksMap = new HashMap<String, Lock>();
2812            private transient ManifestSummary _manifestSummary = new ManifestSummary();
2813            private transient Set<String> _missingReferences = new HashSet<String>();
2814            private transient Element _missingReferencesElement;
2815            private transient List<Layout> _newLayouts;
2816            private Map<String, Map<?, ?>> _newPrimaryKeysMaps =
2817                    new HashMap<String, Map<?, ?>>();
2818            private Set<String> _notUniquePerLayout = new HashSet<String>();
2819            private long _oldPlid;
2820            private Map<String, String[]> _parameterMap;
2821            private Map<String, List<KeyValuePair>> _permissionsMap =
2822                    new HashMap<String, List<KeyValuePair>>();
2823            private long _plid;
2824            private transient PortletDataContextListener _portletDataContextListener;
2825            private String _rootPortletId;
2826            private Set<String> _primaryKeys = new HashSet<String>();
2827            private boolean _privateLayout;
2828            private transient Map<String, List<RatingsEntry>> _ratingsEntriesMap =
2829                    new HashMap<String, List<RatingsEntry>>();
2830            private Set<String> _references = new HashSet<String>();
2831            private Set<String> _scopedPrimaryKeys = new HashSet<String>();
2832            private long _scopeGroupId;
2833            private String _scopeLayoutUuid;
2834            private String _scopeType;
2835            private long _sourceCompanyGroupId;
2836            private long _sourceCompanyId;
2837            private long _sourceGroupId;
2838            private long _sourceUserPersonalSiteGroupId;
2839            private Date _startDate;
2840            private transient UserIdStrategy _userIdStrategy;
2841            private long _userPersonalSiteGroupId;
2842            private transient XStream _xStream;
2843            private transient ZipReader _zipReader;
2844            private transient ZipWriter _zipWriter;
2845    
2846    }