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