001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.kernel.lar;
016    
017    import com.liferay.portal.kernel.backgroundtask.BackgroundTaskThreadLocal;
018    import com.liferay.portal.kernel.log.Log;
019    import com.liferay.portal.kernel.log.LogFactoryUtil;
020    import com.liferay.portal.kernel.util.ArrayUtil;
021    import com.liferay.portal.kernel.util.GetterUtil;
022    import com.liferay.portal.kernel.util.StringPool;
023    import com.liferay.portal.kernel.util.Time;
024    import com.liferay.portal.kernel.util.Validator;
025    import com.liferay.portal.kernel.xml.Document;
026    import com.liferay.portal.kernel.xml.DocumentException;
027    import com.liferay.portal.kernel.xml.Element;
028    import com.liferay.portal.kernel.xml.SAXReaderUtil;
029    import com.liferay.portal.model.Portlet;
030    import com.liferay.portal.service.PortletLocalServiceUtil;
031    import com.liferay.portal.service.PortletPreferencesLocalServiceUtil;
032    import com.liferay.portal.util.PortletKeys;
033    import com.liferay.portlet.dynamicdatamapping.model.DDMTemplate;
034    import com.liferay.portlet.portletdisplaytemplate.util.PortletDisplayTemplate;
035    import com.liferay.portlet.portletdisplaytemplate.util.PortletDisplayTemplateUtil;
036    
037    import java.io.IOException;
038    
039    import java.util.ArrayList;
040    import java.util.List;
041    
042    import javax.portlet.PortletPreferences;
043    
044    /**
045     * @author Brian Wing Shun Chan
046     */
047    public abstract class BasePortletDataHandler implements PortletDataHandler {
048    
049            @Override
050            public PortletPreferences deleteData(
051                            PortletDataContext portletDataContext, String portletId,
052                            PortletPreferences portletPreferences)
053                    throws PortletDataException {
054    
055                    long startTime = 0;
056    
057                    if (_log.isInfoEnabled()) {
058                            _log.info("Deleting portlet " + portletId);
059    
060                            startTime = System.currentTimeMillis();
061                    }
062    
063                    try {
064                            return doDeleteData(
065                                    portletDataContext, portletId, portletPreferences);
066                    }
067                    catch (Exception e) {
068                            throw new PortletDataException(e);
069                    }
070                    finally {
071                            if (_log.isInfoEnabled()) {
072                                    long duration = System.currentTimeMillis() - startTime;
073    
074                                    _log.info("Deleted portlet in " + Time.getDuration(duration));
075                            }
076                    }
077            }
078    
079            @Override
080            public String exportData(
081                            PortletDataContext portletDataContext, String portletId,
082                            PortletPreferences portletPreferences)
083                    throws PortletDataException {
084    
085                    long startTime = 0;
086    
087                    if (_log.isInfoEnabled()) {
088                            _log.info("Exporting portlet " + portletId);
089    
090                            startTime = System.currentTimeMillis();
091                    }
092    
093                    try {
094                            portletDataContext.addDeletionSystemEventStagedModelTypes(
095                                    getDeletionSystemEventStagedModelTypes());
096    
097                            for (PortletDataHandlerControl portletDataHandlerControl :
098                                            getExportControls()) {
099    
100                                    addUncheckedModelAdditionCount(
101                                            portletDataContext, portletDataHandlerControl);
102                            }
103    
104                            if (BackgroundTaskThreadLocal.hasBackgroundTask()) {
105                                    PortletDataContext clonePortletDataContext =
106                                            PortletDataContextFactoryUtil.clonePortletDataContext(
107                                                    portletDataContext);
108    
109                                    prepareManifestSummary(
110                                            clonePortletDataContext, portletPreferences);
111    
112                                    PortletDataHandlerStatusMessageSenderUtil.sendStatusMessage(
113                                            "portlet", portletId,
114                                            clonePortletDataContext.getManifestSummary());
115                            }
116    
117                            return doExportData(
118                                    portletDataContext, portletId, portletPreferences);
119                    }
120                    catch (Exception e) {
121                            throw new PortletDataException(e);
122                    }
123                    finally {
124                            if (_log.isInfoEnabled()) {
125                                    long duration = System.currentTimeMillis() - startTime;
126    
127                                    _log.info("Exported portlet in " + Time.getDuration(duration));
128                            }
129                    }
130            }
131    
132            @Override
133            public DataLevel getDataLevel() {
134                    return _dataLevel;
135            }
136    
137            @Override
138            public String[] getDataPortletPreferences() {
139                    return _dataPortletPreferences;
140            }
141    
142            @Override
143            public StagedModelType[] getDeletionSystemEventStagedModelTypes() {
144                    return _deletionSystemEventStagedModelTypes;
145            }
146    
147            @Override
148            public PortletDataHandlerControl[] getExportConfigurationControls(
149                            long companyId, long groupId, Portlet portlet,
150                            boolean privateLayout)
151                    throws Exception {
152    
153                    return getExportConfigurationControls(
154                            companyId, groupId, portlet, -1, privateLayout);
155            }
156    
157            @Override
158            public PortletDataHandlerControl[] getExportConfigurationControls(
159                            long companyId, long groupId, Portlet portlet, long plid,
160                            boolean privateLayout)
161                    throws Exception {
162    
163                    List<PortletDataHandlerBoolean> configurationControls =
164                            new ArrayList<PortletDataHandlerBoolean>();
165    
166                    // Setup
167    
168                    if ((PortletPreferencesLocalServiceUtil.getPortletPreferencesCount(
169                                    PortletKeys.PREFS_OWNER_ID_DEFAULT,
170                                    PortletKeys.PREFS_OWNER_TYPE_LAYOUT, plid, portlet, false)
171                                    > 0) ||
172                            (PortletPreferencesLocalServiceUtil.getPortletPreferencesCount(
173                                    groupId, PortletKeys.PREFS_OWNER_TYPE_GROUP,
174                                    portlet.getRootPortletId(), false) > 0) ||
175                            (PortletPreferencesLocalServiceUtil.getPortletPreferencesCount(
176                                    companyId, PortletKeys.PREFS_OWNER_TYPE_COMPANY,
177                                    portlet.getRootPortletId(), false) > 0)) {
178    
179                                    configurationControls.add(
180                                            new PortletDataHandlerBoolean(
181                                                    null, PortletDataHandlerKeys.PORTLET_SETUP, "setup",
182                                                    true, false, null, null, null));
183                    }
184    
185                    // Archived setups
186    
187                    if (PortletPreferencesLocalServiceUtil.getPortletPreferencesCount(
188                                    -1, PortletKeys.PREFS_OWNER_TYPE_ARCHIVED,
189                                    portlet.getRootPortletId(), false) > 0) {
190    
191                            configurationControls.add(
192                                    new PortletDataHandlerBoolean(
193                                            null, PortletDataHandlerKeys.PORTLET_ARCHIVED_SETUPS,
194                                            "archived-setups", true, false, null, null, null)
195                            );
196                    }
197    
198                    // User preferences
199    
200                    if ((PortletPreferencesLocalServiceUtil.getPortletPreferencesCount(
201                                    -1, PortletKeys.PREFS_OWNER_TYPE_USER, plid, portlet, false)
202                                    > 0) ||
203                            (PortletPreferencesLocalServiceUtil.getPortletPreferencesCount(
204                                    groupId, PortletKeys.PREFS_OWNER_TYPE_USER,
205                                    PortletKeys.PREFS_PLID_SHARED, portlet, false) > 0)) {
206    
207                            configurationControls.add(
208                                    new PortletDataHandlerBoolean(
209                                            null, PortletDataHandlerKeys.PORTLET_USER_PREFERENCES,
210                                            "user-preferences", true, false, null, null, null));
211                    }
212    
213                    return configurationControls.toArray(
214                            new PortletDataHandlerBoolean[configurationControls.size()]);
215            }
216    
217            @Override
218            public PortletDataHandlerControl[] getExportControls() {
219                    return _exportControls;
220            }
221    
222            @Override
223            public PortletDataHandlerControl[] getExportMetadataControls() {
224                    return _exportMetadataControls;
225            }
226    
227            @Override
228            public long getExportModelCount(ManifestSummary manifestSummary) {
229                    return getExportModelCount(manifestSummary, getExportControls());
230            }
231    
232            @Override
233            public PortletDataHandlerControl[] getImportConfigurationControls(
234                    Portlet portlet, ManifestSummary manifestSummary) {
235    
236                    String[] configurationPortletOptions =
237                            manifestSummary.getConfigurationPortletOptions(
238                                    portlet.getRootPortletId());
239    
240                    return getImportConfigurationControls(configurationPortletOptions);
241            }
242    
243            @Override
244            public PortletDataHandlerControl[] getImportConfigurationControls(
245                    String[] configurationPortletOptions) {
246    
247                    List<PortletDataHandlerBoolean> configurationControls =
248                            new ArrayList<PortletDataHandlerBoolean>();
249    
250                    // Setup
251    
252                    if (ArrayUtil.contains(configurationPortletOptions, "setup")) {
253                            configurationControls.add(
254                                    new PortletDataHandlerBoolean(
255                                            null, PortletDataHandlerKeys.PORTLET_SETUP, "setup", true,
256                                            false, null, null, null));
257                    }
258    
259                    // Archived setups
260    
261                    if (ArrayUtil.contains(
262                                    configurationPortletOptions, "archived-setups")) {
263    
264                            configurationControls.add(
265                                    new PortletDataHandlerBoolean(
266                                            null, PortletDataHandlerKeys.PORTLET_ARCHIVED_SETUPS,
267                                            "archived-setups", true, false, null, null, null));
268                    }
269    
270                    // User preferences
271    
272                    if (ArrayUtil.contains(
273                                    configurationPortletOptions, "user-preferences")) {
274    
275                            configurationControls.add(
276                                    new PortletDataHandlerBoolean(
277                                            null, PortletDataHandlerKeys.PORTLET_USER_PREFERENCES,
278                                            "user-preferences", true, false, null, null, null));
279                    }
280    
281                    return configurationControls.toArray(
282                            new PortletDataHandlerBoolean[configurationControls.size()]);
283            }
284    
285            @Override
286            public PortletDataHandlerControl[] getImportControls() {
287                    return _importControls;
288            }
289    
290            @Override
291            public PortletDataHandlerControl[] getImportMetadataControls() {
292                    return _importMetadataControls;
293            }
294    
295            @Override
296            public String getPortletId() {
297                    return _portletId;
298            }
299    
300            @Override
301            public PortletPreferences importData(
302                            PortletDataContext portletDataContext, String portletId,
303                            PortletPreferences portletPreferences, String data)
304                    throws PortletDataException {
305    
306                    long startTime = 0;
307    
308                    if (_log.isInfoEnabled()) {
309                            _log.info("Importing portlet " + portletId);
310    
311                            startTime = System.currentTimeMillis();
312                    }
313    
314                    long sourceGroupId = portletDataContext.getSourceGroupId();
315    
316                    try {
317                            if (Validator.isXml(data)) {
318                                    addImportDataRootElement(portletDataContext, data);
319                            }
320    
321                            portletDataContext.addDeletionSystemEventStagedModelTypes(
322                                    getDeletionSystemEventStagedModelTypes());
323    
324                            return doImportData(
325                                    portletDataContext, portletId, portletPreferences, data);
326                    }
327                    catch (Exception e) {
328                            throw new PortletDataException(e);
329                    }
330                    finally {
331                            portletDataContext.setSourceGroupId(sourceGroupId);
332    
333                            if (_log.isInfoEnabled()) {
334                                    long duration = System.currentTimeMillis() - startTime;
335    
336                                    _log.info("Imported portlet in " + Time.getDuration(duration));
337                            }
338                    }
339            }
340    
341            @Override
342            public boolean isDataLocalized() {
343                    return _dataLocalized;
344            }
345    
346            @Override
347            public boolean isDataPortalLevel() {
348                    return _dataLevel.equals(DataLevel.PORTAL);
349            }
350    
351            @Override
352            public boolean isDataPortletInstanceLevel() {
353                    return _dataLevel.equals(DataLevel.PORTLET_INSTANCE);
354            }
355    
356            @Override
357            public boolean isDataSiteLevel() {
358                    return _dataLevel.equals(DataLevel.SITE);
359            }
360    
361            @Override
362            public boolean isDisplayPortlet() {
363                    if (isDataPortletInstanceLevel() &&
364                            !ArrayUtil.isEmpty(getDataPortletPreferences())) {
365    
366                            return true;
367                    }
368    
369                    return false;
370            }
371    
372            @Override
373            public boolean isPublishToLiveByDefault() {
374                    return _publishToLiveByDefault;
375            }
376    
377            @Override
378            public boolean isSupportsDataStrategyCopyAsNew() {
379                    return _supportsDataStrategyCopyAsNew;
380            }
381    
382            @Override
383            public void prepareManifestSummary(PortletDataContext portletDataContext)
384                    throws PortletDataException {
385    
386                    prepareManifestSummary(portletDataContext, null);
387            }
388    
389            @Override
390            public void prepareManifestSummary(
391                            PortletDataContext portletDataContext,
392                            PortletPreferences portletPreferences)
393                    throws PortletDataException {
394    
395                    try {
396                            doPrepareManifestSummary(portletDataContext, portletPreferences);
397                    }
398                    catch (Exception e) {
399                            throw new PortletDataException(e);
400                    }
401            }
402    
403            @Override
404            public PortletPreferences processExportPortletPreferences(
405                            PortletDataContext portletDataContext, String portletId,
406                            PortletPreferences portletPreferences)
407                    throws PortletDataException {
408    
409                    String displayStyle = getDisplayTemplate(
410                            portletDataContext, portletId, portletPreferences);
411    
412                    if (Validator.isNotNull(displayStyle) &&
413                            displayStyle.startsWith(
414                                    PortletDisplayTemplate.DISPLAY_STYLE_PREFIX)) {
415    
416                            long displayStyleGroupId = getDisplayTemplateGroupId(
417                                    portletDataContext, portletId, portletPreferences);
418    
419                            long previousScopeGroupId = portletDataContext.getScopeGroupId();
420    
421                            if (displayStyleGroupId != portletDataContext.getScopeGroupId()) {
422                                    portletDataContext.setScopeGroupId(displayStyleGroupId);
423                            }
424    
425                            DDMTemplate ddmTemplate =
426                                    PortletDisplayTemplateUtil.fetchDDMTemplate(
427                                            portletDataContext.getGroupId(), displayStyle);
428    
429                            if (ddmTemplate != null) {
430                                    StagedModelDataHandlerUtil.exportReferenceStagedModel(
431                                            portletDataContext, portletId, ddmTemplate);
432                            }
433    
434                            portletDataContext.setScopeGroupId(previousScopeGroupId);
435                    }
436    
437                    try {
438                            return doProcessExportPortletPreferences(
439                                    portletDataContext, portletId, portletPreferences);
440                    }
441                    catch (Exception e) {
442                            throw new PortletDataException(e);
443                    }
444            }
445    
446            @Override
447            public PortletPreferences processImportPortletPreferences(
448                            PortletDataContext portletDataContext, String portletId,
449                            PortletPreferences portletPreferences)
450                    throws PortletDataException {
451    
452                    try {
453                            String displayStyle = getDisplayTemplate(
454                                    portletDataContext, portletId, portletPreferences);
455    
456                            if (Validator.isNotNull(displayStyle) &&
457                                    displayStyle.startsWith(
458                                            PortletDisplayTemplate.DISPLAY_STYLE_PREFIX)) {
459    
460                                    DDMTemplate ddmTemplate = null;
461    
462                                    long displayStyleGroupId = getDisplayTemplateGroupId(
463                                            portletDataContext, portletId, portletPreferences);
464    
465                                    if (displayStyleGroupId ==
466                                                    portletDataContext.getCompanyGroupId()) {
467    
468                                            ddmTemplate = PortletDisplayTemplateUtil.fetchDDMTemplate(
469                                                    portletDataContext.getCompanyGroupId(), displayStyle);
470                                    }
471                                    else if (displayStyleGroupId ==
472                                                            portletDataContext.getSourceGroupId()) {
473    
474                                            ddmTemplate = PortletDisplayTemplateUtil.fetchDDMTemplate(
475                                                    portletDataContext.getScopeGroupId(), displayStyle);
476                                    }
477                                    else {
478                                            ddmTemplate = PortletDisplayTemplateUtil.fetchDDMTemplate(
479                                                    displayStyleGroupId, displayStyle);
480                                    }
481    
482                                    long importedDisplayStyleGroupId =
483                                            portletDataContext.getScopeGroupId();
484    
485                                    if (ddmTemplate == null) {
486                                            String ddmTemplateUuid =
487                                                    PortletDisplayTemplateUtil.getDDMTemplateUuid(
488                                                            displayStyle);
489    
490                                            Element ddmTemplateElement =
491                                                    portletDataContext.getImportDataElement(
492                                                            DDMTemplate.class.getSimpleName(), "uuid",
493                                                            ddmTemplateUuid);
494    
495                                            String ddmTemplatePath = ddmTemplateElement.attributeValue(
496                                                    "path");
497    
498                                            ddmTemplate =
499                                                    (DDMTemplate)portletDataContext.getZipEntryAsObject(
500                                                            ddmTemplatePath);
501    
502                                            if (ddmTemplate != null) {
503                                                    StagedModelDataHandlerUtil.importStagedModel(
504                                                            portletDataContext, ddmTemplate);
505                                            }
506                                    }
507                                    else {
508                                            importedDisplayStyleGroupId = ddmTemplate.getGroupId();
509                                    }
510    
511                                    portletPreferences.setValue(
512                                            "displayStyleGroupId",
513                                            String.valueOf(importedDisplayStyleGroupId));
514                            }
515                            else {
516                                    portletPreferences.setValue(
517                                            "displayStyleGroupId", StringPool.BLANK);
518                            }
519    
520                            return doProcessImportPortletPreferences(
521                                    portletDataContext, portletId, portletPreferences);
522                    }
523                    catch (Exception e) {
524                            throw new PortletDataException(e);
525                    }
526            }
527    
528            @Override
529            public void setPortletId(String portletId) {
530                    _portletId = portletId;
531            }
532    
533            protected Element addExportDataRootElement(
534                    PortletDataContext portletDataContext) {
535    
536                    Document document = SAXReaderUtil.createDocument();
537    
538                    Class<?> clazz = getClass();
539    
540                    Element rootElement = document.addElement(clazz.getSimpleName());
541    
542                    portletDataContext.setExportDataRootElement(rootElement);
543    
544                    return rootElement;
545            }
546    
547            protected Element addImportDataRootElement(
548                            PortletDataContext portletDataContext, String data)
549                    throws DocumentException {
550    
551                    Document document = SAXReaderUtil.read(data);
552    
553                    Element rootElement = document.getRootElement();
554    
555                    portletDataContext.setImportDataRootElement(rootElement);
556    
557                    long groupId = GetterUtil.getLong(
558                            rootElement.attributeValue("group-id"));
559    
560                    if (groupId != 0) {
561                            portletDataContext.setSourceGroupId(groupId);
562                    }
563    
564                    return rootElement;
565            }
566    
567            protected void addUncheckedModelAdditionCount(
568                    PortletDataContext portletDataContext,
569                    PortletDataHandlerControl portletDataHandlerControl) {
570    
571                    if (!(portletDataHandlerControl instanceof PortletDataHandlerBoolean)) {
572                            return;
573                    }
574    
575                    PortletDataHandlerBoolean portletDataHandlerBoolean =
576                            (PortletDataHandlerBoolean)portletDataHandlerControl;
577    
578                    PortletDataHandlerControl[] childPortletDataHandlerControls =
579                            portletDataHandlerBoolean.getChildren();
580    
581                    if (childPortletDataHandlerControls != null) {
582                            for (PortletDataHandlerControl childPortletDataHandlerControl :
583                                            childPortletDataHandlerControls) {
584    
585                                    addUncheckedModelAdditionCount(
586                                            portletDataContext, childPortletDataHandlerControl);
587                            }
588                    }
589    
590                    if (Validator.isNull(portletDataHandlerControl.getClassName())) {
591                            return;
592                    }
593    
594                    boolean checkedControl = GetterUtil.getBoolean(
595                            portletDataContext.getBooleanParameter(
596                                    portletDataHandlerControl.getNamespace(),
597                                    portletDataHandlerControl.getControlName(), false));
598    
599                    if (!checkedControl) {
600                            ManifestSummary manifestSummary =
601                                    portletDataContext.getManifestSummary();
602    
603                            String manifestSummaryKey = ManifestSummary.getManifestSummaryKey(
604                                    portletDataHandlerControl.getClassName(),
605                                    portletDataHandlerBoolean.getReferrerClassName());
606    
607                            manifestSummary.addModelAdditionCount(manifestSummaryKey, 0);
608                    }
609            }
610    
611            protected PortletPreferences doDeleteData(
612                            PortletDataContext portletDataContext, String portletId,
613                            PortletPreferences portletPreferences)
614                    throws Exception {
615    
616                    return portletPreferences;
617            }
618    
619            protected String doExportData(
620                            PortletDataContext portletDataContext, String portletId,
621                            PortletPreferences portletPreferences)
622                    throws Exception {
623    
624                    return null;
625            }
626    
627            protected PortletPreferences doImportData(
628                            PortletDataContext portletDataContext, String portletId,
629                            PortletPreferences portletPreferences, String data)
630                    throws Exception {
631    
632                    return null;
633            }
634    
635            protected void doPrepareManifestSummary(
636                            PortletDataContext portletDataContext,
637                            PortletPreferences portletPreferences)
638                    throws Exception {
639            }
640    
641            protected PortletPreferences doProcessExportPortletPreferences(
642                            PortletDataContext portletDataContext, String portletId,
643                            PortletPreferences portletPreferences)
644                    throws Exception {
645    
646                    return portletPreferences;
647            }
648    
649            protected PortletPreferences doProcessImportPortletPreferences(
650                            PortletDataContext portletDataContext, String portletId,
651                            PortletPreferences portletPreferences)
652                    throws Exception {
653    
654                    return portletPreferences;
655            }
656    
657            protected String getDisplayTemplate(
658                    PortletDataContext portletDataContext, String portletId,
659                    PortletPreferences portletPreferences) {
660    
661                    try {
662                            Portlet portlet = PortletLocalServiceUtil.getPortletById(
663                                    portletDataContext.getCompanyId(), portletId);
664    
665                            if (Validator.isNotNull(portlet.getTemplateHandlerClass())) {
666                                    return portletPreferences.getValue("displayStyle", null);
667                            }
668                    }
669                    catch (Exception e) {
670                    }
671    
672                    return null;
673            }
674    
675            protected long getDisplayTemplateGroupId(
676                    PortletDataContext portletDataContext, String portletId,
677                    PortletPreferences portletPreferences) {
678    
679                    try {
680                            Portlet portlet = PortletLocalServiceUtil.getPortletById(
681                                    portletDataContext.getCompanyId(), portletId);
682    
683                            if (Validator.isNotNull(portlet.getTemplateHandlerClass())) {
684                                    return GetterUtil.getLong(
685                                            portletPreferences.getValue("displayStyleGroupId", null));
686                            }
687                    }
688                    catch (Exception e) {
689                    }
690    
691                    return 0;
692            }
693    
694            protected String getExportDataRootElementString(Element rootElement) {
695                    if (rootElement == null) {
696                            return StringPool.BLANK;
697                    }
698    
699                    try {
700                            Document document = rootElement.getDocument();
701    
702                            return document.formattedString();
703                    }
704                    catch (IOException ioe) {
705                            return StringPool.BLANK;
706                    }
707            }
708    
709            protected long getExportModelCount(
710                    ManifestSummary manifestSummary,
711                    PortletDataHandlerControl[] portletDataHandlerControls) {
712    
713                    long totalModelCount = -1;
714    
715                    for (PortletDataHandlerControl portletDataHandlerControl :
716                                    portletDataHandlerControls) {
717    
718                            long modelCount = manifestSummary.getModelAdditionCount(
719                                    portletDataHandlerControl.getClassName(),
720                                    portletDataHandlerControl.getReferrerClassName());
721    
722                            if (portletDataHandlerControl
723                                            instanceof PortletDataHandlerBoolean) {
724    
725                                    PortletDataHandlerBoolean portletDataHandlerBoolean =
726                                            (PortletDataHandlerBoolean)portletDataHandlerControl;
727    
728                                    PortletDataHandlerControl[] childPortletDataHandlerControls =
729                                            portletDataHandlerBoolean.getChildren();
730    
731                                    if (childPortletDataHandlerControls != null) {
732                                            long childModelCount = getExportModelCount(
733                                                    manifestSummary, childPortletDataHandlerControls);
734    
735                                            if (childModelCount != -1) {
736                                                    if (modelCount == -1) {
737                                                            modelCount = childModelCount;
738                                                    }
739                                                    else {
740                                                            modelCount += childModelCount;
741                                                    }
742                                            }
743                                    }
744                            }
745    
746                            if (modelCount == -1) {
747                                    continue;
748                            }
749    
750                            if (totalModelCount == -1) {
751                                    totalModelCount = modelCount;
752                            }
753                            else {
754                                    totalModelCount += modelCount;
755                            }
756                    }
757    
758                    return totalModelCount;
759            }
760    
761            /**
762             * @deprecated As of 6.2.0
763             */
764            protected void setAlwaysExportable(boolean alwaysExportable) {
765            }
766    
767            /**
768             * @deprecated As of 6.2.0
769             */
770            protected void setAlwaysStaged(boolean alwaysStaged) {
771            }
772    
773            protected void setDataLevel(DataLevel dataLevel) {
774                    _dataLevel = dataLevel;
775            }
776    
777            protected void setDataLocalized(boolean dataLocalized) {
778                    _dataLocalized = dataLocalized;
779            }
780    
781            protected void setDataPortletPreferences(String... dataPortletPreferences) {
782                    _dataPortletPreferences = dataPortletPreferences;
783            }
784    
785            protected void setDeletionSystemEventStagedModelTypes(
786                    StagedModelType... deletionSystemEventStagedModelTypes) {
787    
788                    _deletionSystemEventStagedModelTypes =
789                            deletionSystemEventStagedModelTypes;
790            }
791    
792            protected void setExportControls(
793                    PortletDataHandlerControl... exportControls) {
794    
795                    _exportControls = exportControls;
796    
797                    setImportControls(exportControls);
798            }
799    
800            protected void setExportMetadataControls(
801                    PortletDataHandlerControl... exportMetadataControls) {
802    
803                    _exportMetadataControls = exportMetadataControls;
804    
805                    setImportMetadataControls(exportMetadataControls);
806            }
807    
808            protected void setImportControls(
809                    PortletDataHandlerControl... importControls) {
810    
811                    _importControls = importControls;
812            }
813    
814            protected void setImportMetadataControls(
815                    PortletDataHandlerControl... importMetadataControls) {
816    
817                    _importMetadataControls = importMetadataControls;
818            }
819    
820            protected void setPublishToLiveByDefault(boolean publishToLiveByDefault) {
821                    _publishToLiveByDefault = publishToLiveByDefault;
822            }
823    
824            protected void setSupportsDataStrategyCopyAsNew(
825                    boolean supportsDataStrategyCopyAsNew) {
826    
827                    _supportsDataStrategyCopyAsNew = supportsDataStrategyCopyAsNew;
828            }
829    
830            private static Log _log = LogFactoryUtil.getLog(
831                    BasePortletDataHandler.class);
832    
833            private DataLevel _dataLevel = DataLevel.SITE;
834            private boolean _dataLocalized;
835            private String[] _dataPortletPreferences = StringPool.EMPTY_ARRAY;
836            private StagedModelType[] _deletionSystemEventStagedModelTypes =
837                    new StagedModelType[0];
838            private PortletDataHandlerControl[] _exportControls =
839                    new PortletDataHandlerControl[0];
840            private PortletDataHandlerControl[] _exportMetadataControls =
841                    new PortletDataHandlerControl[0];
842            private PortletDataHandlerControl[] _importControls =
843                    new PortletDataHandlerControl[0];
844            private PortletDataHandlerControl[] _importMetadataControls =
845                    new PortletDataHandlerControl[0];
846            private String _portletId;
847            private boolean _publishToLiveByDefault;
848            private boolean _supportsDataStrategyCopyAsNew = true;
849    
850    }