001    /**
002     * Copyright (c) 2000-present 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.portlet.dynamicdatamapping.service.impl;
016    
017    import com.liferay.portal.kernel.exception.PortalException;
018    import com.liferay.portal.kernel.util.OrderByComparator;
019    import com.liferay.portal.security.permission.ActionKeys;
020    import com.liferay.portal.service.ServiceContext;
021    import com.liferay.portlet.dynamicdatamapping.model.DDMForm;
022    import com.liferay.portlet.dynamicdatamapping.model.DDMFormLayout;
023    import com.liferay.portlet.dynamicdatamapping.model.DDMStructure;
024    import com.liferay.portlet.dynamicdatamapping.service.base.DDMStructureServiceBaseImpl;
025    import com.liferay.portlet.dynamicdatamapping.service.permission.DDMPermission;
026    import com.liferay.portlet.dynamicdatamapping.service.permission.DDMStructurePermission;
027    import com.liferay.portlet.dynamicdatamapping.util.DDMPermissionHandler;
028    import com.liferay.portlet.dynamicdatamapping.util.DDMUtil;
029    
030    import java.util.List;
031    import java.util.Locale;
032    import java.util.Map;
033    
034    /**
035     * Provides the remote service for accessing, adding, deleting, and updating
036     * dynamic data mapping (DDM) structures. Its methods include permission checks.
037     *
038     * @author Brian Wing Shun Chan
039     * @author Bruno Basto
040     * @author Marcellus Tavares
041     * @see    com.liferay.portlet.dynamicdatamapping.service.impl.DDMStructureLocalServiceImpl
042     */
043    public class DDMStructureServiceImpl extends DDMStructureServiceBaseImpl {
044    
045            @Override
046            public DDMStructure addStructure(
047                            long userId, long groupId, long classNameId,
048                            Map<Locale, String> nameMap, Map<Locale, String> descriptionMap,
049                            DDMForm ddmForm, DDMFormLayout ddmFormLayout,
050                            ServiceContext serviceContext)
051                    throws PortalException {
052    
053                    DDMPermissionHandler ddmPermissionHandler =
054                            DDMUtil.getDDMPermissionHandler(classNameId);
055    
056                    DDMPermission.check(
057                            getPermissionChecker(), serviceContext.getScopeGroupId(),
058                            ddmPermissionHandler.getResourceName(classNameId),
059                            ddmPermissionHandler.getAddStructureActionId());
060    
061                    return ddmStructureLocalService.addStructure(
062                            getUserId(), groupId, classNameId, nameMap, descriptionMap, ddmForm,
063                            ddmFormLayout, serviceContext);
064            }
065    
066            /**
067             * Adds a structure referencing a default parent structure, using the portal
068             * property <code>dynamic.data.lists.storage.type</code> storage type and
069             * default structure type.
070             *
071             * @param      userId the primary key of the structure's creator/owner
072             * @param      groupId the primary key of the group
073             * @param      classNameId the primary key of the class name for the
074             *             structure's related model
075             * @param      nameMap the structure's locales and localized names
076             * @param      descriptionMap the structure's locales and localized
077             *             descriptions
078             * @param      xsd the structure's XML schema definition
079             * @param      serviceContext the service context to be applied. Can set the
080             *             UUID, creation date, modification date, guest permissions,
081             *             and group permissions for the structure.
082             * @return     the structure
083             * @throws     PortalException if a user with the primary key could not be
084             *             found, if the user did not have permission to add the
085             *             structure, if the XSD was not well-formed, or if a portal
086             *             exception occurred
087             * @deprecated As of 7.0.0, replaced by {@link #addStructure(long, long,
088             *             long, Map, Map, DDMForm, DDMFormLayout, ServiceContext)}
089             */
090            @Deprecated
091            @Override
092            public DDMStructure addStructure(
093                            long userId, long groupId, long classNameId,
094                            Map<Locale, String> nameMap, Map<Locale, String> descriptionMap,
095                            String xsd, ServiceContext serviceContext)
096                    throws PortalException {
097    
098                    DDMPermissionHandler ddmPermissionHandler =
099                            DDMUtil.getDDMPermissionHandler(classNameId);
100    
101                    DDMPermission.check(
102                            getPermissionChecker(), serviceContext.getScopeGroupId(),
103                            ddmPermissionHandler.getResourceName(classNameId),
104                            ddmPermissionHandler.getAddStructureActionId());
105    
106                    return ddmStructureLocalService.addStructure(
107                            getUserId(), groupId, classNameId, nameMap, descriptionMap, xsd,
108                            serviceContext);
109            }
110    
111            @Override
112            public DDMStructure addStructure(
113                            long groupId, long parentStructureId, long classNameId,
114                            String structureKey, Map<Locale, String> nameMap,
115                            Map<Locale, String> descriptionMap, DDMForm ddmForm,
116                            DDMFormLayout ddmFormLayout, String storageType, int type,
117                            ServiceContext serviceContext)
118                    throws PortalException {
119    
120                    DDMPermissionHandler ddmPermissionHandler =
121                            DDMUtil.getDDMPermissionHandler(classNameId);
122    
123                    DDMPermission.check(
124                            getPermissionChecker(), serviceContext.getScopeGroupId(),
125                            ddmPermissionHandler.getResourceName(classNameId),
126                            ddmPermissionHandler.getAddStructureActionId());
127    
128                    return ddmStructureLocalService.addStructure(
129                            getUserId(), groupId, parentStructureId, classNameId, structureKey,
130                            nameMap, descriptionMap, ddmForm, ddmFormLayout, storageType, type,
131                            serviceContext);
132            }
133    
134            /**
135             * Adds a structure referencing its parent structure.
136             *
137             * @param      groupId the primary key of the group
138             * @param      parentStructureId the primary key of the parent structure
139             *             (optionally {@link
140             *             com.liferay.portlet.dynamicdatamapping.model.DDMStructureConstants#DEFAULT_PARENT_STRUCTURE_ID})
141             * @param      classNameId the primary key of the class name for the
142             *             structure's related model
143             * @param      structureKey the unique string identifying the structure
144             *             (optionally <code>null</code>)
145             * @param      nameMap the structure's locales and localized names
146             * @param      descriptionMap the structure's locales and localized
147             *             descriptions
148             * @param      xsd the structure's XML schema definition
149             * @param      storageType the structure's storage type. It can be "xml" or
150             *             "expando". For more information, see {@link
151             *             com.liferay.portlet.dynamicdatamapping.storage.StorageType}.
152             * @param      type the structure's type. For more information, see {@link
153             *             com.liferay.portlet.dynamicdatamapping.model.DDMStructureConstants}.
154             * @param      serviceContext the service context to be applied. Can set the
155             *             UUID, creation date, modification date, guest permissions,
156             *             and group permissions for the structure.
157             * @return     the structure
158             * @throws     PortalException if the user did not have permission to add
159             *             the structure, if the XSD is not well formed, or if a portal
160             *             exception occurred
161             * @deprecated As of 7.0.0, replaced by {@link #addStructure(long, long,
162             *             long, String, Map, Map, DDMForm, DDMFormLayout, String, int,
163             *             ServiceContext)}
164             */
165            @Deprecated
166            @Override
167            public DDMStructure addStructure(
168                            long groupId, long parentStructureId, long classNameId,
169                            String structureKey, Map<Locale, String> nameMap,
170                            Map<Locale, String> descriptionMap, String xsd, String storageType,
171                            int type, ServiceContext serviceContext)
172                    throws PortalException {
173    
174                    DDMPermissionHandler ddmPermissionHandler =
175                            DDMUtil.getDDMPermissionHandler(classNameId);
176    
177                    DDMPermission.check(
178                            getPermissionChecker(), serviceContext.getScopeGroupId(),
179                            ddmPermissionHandler.getResourceName(classNameId),
180                            ddmPermissionHandler.getAddStructureActionId());
181    
182                    return ddmStructureLocalService.addStructure(
183                            getUserId(), groupId, parentStructureId, classNameId, structureKey,
184                            nameMap, descriptionMap, xsd, storageType, type, serviceContext);
185            }
186    
187            @Override
188            public DDMStructure addStructure(
189                            long userId, long groupId, String parentStructureKey,
190                            long classNameId, String structureKey, Map<Locale, String> nameMap,
191                            Map<Locale, String> descriptionMap, DDMForm ddmForm,
192                            DDMFormLayout ddmFormLayout, String storageType, int type,
193                            ServiceContext serviceContext)
194                    throws PortalException {
195    
196                    DDMPermissionHandler ddmPermissionHandler =
197                            DDMUtil.getDDMPermissionHandler(classNameId);
198    
199                    DDMPermission.check(
200                            getPermissionChecker(), serviceContext.getScopeGroupId(),
201                            ddmPermissionHandler.getResourceName(classNameId),
202                            ddmPermissionHandler.getAddStructureActionId());
203    
204                    return ddmStructureLocalService.addStructure(
205                            userId, groupId, parentStructureKey, classNameId, structureKey,
206                            nameMap, descriptionMap, ddmForm, ddmFormLayout, storageType, type,
207                            serviceContext);
208            }
209    
210            /**
211             * Adds a structure referencing the parent structure by its structure key.
212             * In case the parent structure is not found, it uses the default parent
213             * structure ID.
214             *
215             * @param      userId the primary key of the structure's creator/owner
216             * @param      groupId the primary key of the group
217             * @param      parentStructureKey the unique string identifying the
218             *             structure
219             * @param      classNameId the primary key of the class name for the
220             *             structure's related model
221             * @param      structureKey unique string identifying the structure
222             *             (optionally <code>null</code>)
223             * @param      nameMap the structure's locales and localized names
224             * @param      descriptionMap the structure's locales and localized
225             *             descriptions
226             * @param      xsd the XML schema definition of the structure
227             * @param      storageType the storage type of the structure. It can be XML
228             *             or expando. For more information, see {@link
229             *             com.liferay.portlet.dynamicdatamapping.storage.StorageType}.
230             * @param      type the structure's type. For more information, see {@link
231             *             com.liferay.portlet.dynamicdatamapping.model.DDMStructureConstants}.
232             * @param      serviceContext the service context to be applied. Must have
233             *             the <code>ddmResource</code> attribute to check permissions.
234             *             Can set the UUID, creation date, modification date, guest
235             *             permissions, and group permissions for the structure.
236             * @return     the structure
237             * @throws     PortalException if a user with the primary key could not be
238             *             found, if the user did not have permission to add the
239             *             structure, if the XSD was not well-formed, or if a portal
240             *             exception occurred
241             * @deprecated As of 7.0.0, replaced by {@link #addStructure(long, long,
242             *             String, long, String, Map, Map, DDMForm, DDMFormLayout,
243             *             String, int, ServiceContext)}
244             */
245            @Deprecated
246            @Override
247            public DDMStructure addStructure(
248                            long userId, long groupId, String parentStructureKey,
249                            long classNameId, String structureKey, Map<Locale, String> nameMap,
250                            Map<Locale, String> descriptionMap, String xsd, String storageType,
251                            int type, ServiceContext serviceContext)
252                    throws PortalException {
253    
254                    DDMPermissionHandler ddmPermissionHandler =
255                            DDMUtil.getDDMPermissionHandler(classNameId);
256    
257                    DDMPermission.check(
258                            getPermissionChecker(), serviceContext.getScopeGroupId(),
259                            ddmPermissionHandler.getResourceName(classNameId),
260                            ddmPermissionHandler.getAddStructureActionId());
261    
262                    return ddmStructureLocalService.addStructure(
263                            userId, groupId, parentStructureKey, classNameId, structureKey,
264                            nameMap, descriptionMap, xsd, storageType, type, serviceContext);
265            }
266    
267            /**
268             * Copies a structure, creating a new structure with all the values
269             * extracted from the original one. The new structure supports a new name
270             * and description.
271             *
272             * @param  structureId the primary key of the structure to be copied
273             * @param  nameMap the new structure's locales and localized names
274             * @param  descriptionMap the new structure's locales and localized
275             *         descriptions
276             * @param  serviceContext the service context to be applied. Can set the
277             *         UUID, creation date, modification date, guest permissions, and
278             *         group permissions for the structure.
279             * @return the new structure
280             * @throws PortalException if the user did not have permission to add the
281             *         structure or if a portal exception occurred
282             */
283            @Override
284            public DDMStructure copyStructure(
285                            long structureId, Map<Locale, String> nameMap,
286                            Map<Locale, String> descriptionMap, ServiceContext serviceContext)
287                    throws PortalException {
288    
289                    DDMStructure structure = ddmStructurePersistence.findByPrimaryKey(
290                            structureId);
291    
292                    DDMPermissionHandler ddmPermissionHandler =
293                            DDMUtil.getDDMPermissionHandler(structure.getClassNameId());
294    
295                    DDMPermission.check(
296                            getPermissionChecker(), serviceContext.getScopeGroupId(),
297                            ddmPermissionHandler.getResourceName(structure.getClassNameId()),
298                            ddmPermissionHandler.getAddStructureActionId());
299    
300                    return ddmStructureLocalService.copyStructure(
301                            getUserId(), structureId, nameMap, descriptionMap, serviceContext);
302            }
303    
304            @Override
305            public DDMStructure copyStructure(
306                            long structureId, ServiceContext serviceContext)
307                    throws PortalException {
308    
309                    DDMStructure structure = ddmStructurePersistence.findByPrimaryKey(
310                            structureId);
311    
312                    DDMPermissionHandler ddmPermissionHandler =
313                            DDMUtil.getDDMPermissionHandler(structure.getClassNameId());
314    
315                    DDMPermission.check(
316                            getPermissionChecker(), serviceContext.getScopeGroupId(),
317                            ddmPermissionHandler.getResourceName(structure.getClassNameId()),
318                            ddmPermissionHandler.getAddStructureActionId());
319    
320                    return ddmStructureLocalService.copyStructure(
321                            getUserId(), structureId, serviceContext);
322            }
323    
324            /**
325             * Deletes the structure and its resources.
326             *
327             * <p>
328             * Before deleting the structure, the system verifies whether the structure
329             * is required by another entity. If it is needed, an exception is thrown.
330             * </p>
331             *
332             * @param  structureId the primary key of the structure to be deleted
333             * @throws PortalException if the user did not have permission to delete the
334             *         structure or if a portal exception occurred
335             */
336            @Override
337            public void deleteStructure(long structureId) throws PortalException {
338                    DDMStructurePermission.check(
339                            getPermissionChecker(), structureId, ActionKeys.DELETE);
340    
341                    ddmStructureLocalService.deleteStructure(structureId);
342            }
343    
344            /**
345             * Returns the structure matching the class name ID, structure key, and
346             * group.
347             *
348             * @param  groupId the primary key of the group
349             * @param  classNameId the primary key of the class name for the structure's
350             *         related model
351             * @param  structureKey the unique string identifying the structure
352             * @return the matching structure, or <code>null</code> if a matching
353             *         structure could not be found
354             * @throws PortalException if the user did not have permission to view the
355             *         structure or if a portal exception occurred
356             */
357            @Override
358            public DDMStructure fetchStructure(
359                            long groupId, long classNameId, String structureKey)
360                    throws PortalException {
361    
362                    DDMStructure ddmStructure = ddmStructurePersistence.fetchByG_C_S(
363                            groupId, classNameId, structureKey);
364    
365                    if (ddmStructure != null) {
366                            DDMStructurePermission.check(
367                                    getPermissionChecker(), ddmStructure, ActionKeys.VIEW);
368                    }
369    
370                    return ddmStructure;
371            }
372    
373            @Override
374            public DDMStructure fetchStructure(
375                            long groupId, long classNameId, String structureKey,
376                            boolean includeAncestorStructures)
377                    throws PortalException {
378    
379                    DDMStructure ddmStructure = ddmStructureLocalService.fetchStructure(
380                            groupId, classNameId, structureKey, includeAncestorStructures);
381    
382                    if (ddmStructure != null) {
383                            DDMStructurePermission.check(
384                                    getPermissionChecker(), ddmStructure, ActionKeys.VIEW);
385                    }
386    
387                    return ddmStructure;
388            }
389    
390            /**
391             * Returns the structure with the ID.
392             *
393             * @param  structureId the primary key of the structure
394             * @return the structure with the ID
395             * @throws PortalException if the user did not have permission to view the
396             *         structure or if a structure with the ID could not be found
397             */
398            @Override
399            public DDMStructure getStructure(long structureId) throws PortalException {
400                    DDMStructurePermission.check(
401                            getPermissionChecker(), structureId, ActionKeys.VIEW);
402    
403                    return ddmStructurePersistence.findByPrimaryKey(structureId);
404            }
405    
406            /**
407             * Returns the structure matching the class name ID, structure key, and
408             * group.
409             *
410             * @param  groupId the primary key of the structure's group
411             * @param  classNameId the primary key of the class name for the structure's
412             *         related model
413             * @param  structureKey the unique string identifying the structure
414             * @return the matching structure
415             * @throws PortalException if the user did not have permission to view the
416             *         structure or if a matching structure could not be found
417             */
418            @Override
419            public DDMStructure getStructure(
420                            long groupId, long classNameId, String structureKey)
421                    throws PortalException {
422    
423                    DDMStructurePermission.check(
424                            getPermissionChecker(), groupId, classNameId, structureKey,
425                            ActionKeys.VIEW);
426    
427                    return ddmStructureLocalService.getStructure(
428                            groupId, classNameId, structureKey);
429            }
430    
431            /**
432             * Returns the structure matching the class name ID, structure key, and
433             * group, optionally searching ancestor sites (that have sharing enabled)
434             * and global scoped sites.
435             *
436             * <p>
437             * This method first searches in the group. If the structure is still not
438             * found and <code>includeAncestorStructures</code> is set to
439             * <code>true</code>, this method searches the group's ancestor sites (that
440             * have sharing enabled) and lastly searches global scoped sites.
441             * </p>
442             *
443             * @param  groupId the primary key of the structure's group
444             * @param  classNameId the primary key of the class name for the structure's
445             *         related model
446             * @param  structureKey the unique string identifying the structure
447             * @param  includeAncestorStructures whether to include ancestor sites (that
448             *         have sharing enabled) and include global scoped sites in the
449             *         search
450             * @return the matching structure
451             * @throws PortalException if the user did not have permission to view the
452             *         structure or if a matching structure could not be found
453             */
454            @Override
455            public DDMStructure getStructure(
456                            long groupId, long classNameId, String structureKey,
457                            boolean includeAncestorStructures)
458                    throws PortalException {
459    
460                    DDMStructurePermission.check(
461                            getPermissionChecker(), groupId, classNameId, structureKey,
462                            ActionKeys.VIEW);
463    
464                    return ddmStructureLocalService.getStructure(
465                            groupId, classNameId, structureKey, includeAncestorStructures);
466            }
467    
468            /**
469             * Returns all the structures in the group that the user has permission to
470             * view.
471             *
472             * @param  groupId the primary key of the group
473             * @return the structures in the group that the user has permission to view
474             */
475            @Override
476            public List<DDMStructure> getStructures(long groupId) {
477                    return ddmStructurePersistence.filterFindByGroupId(groupId);
478            }
479    
480            /**
481             * Returns all the structures in the groups that the user has permission to
482             * view.
483             *
484             * @param  groupIds the primary key of the groups
485             * @return the structures in the groups that the user has permission to view
486             */
487            @Override
488            public List<DDMStructure> getStructures(long[] groupIds) {
489                    return ddmStructurePersistence.filterFindByGroupId(groupIds);
490            }
491    
492            /**
493             * Returns all the structures matching the groups and class name ID that the
494             * user has permission to view.
495             *
496             * @param  groupIds the primary keys of the groups
497             * @param  classNameId the primary key of the class name for the structure's
498             *         related model
499             * @return the structures matching the groups and class name ID that the
500             *         user has permission to view
501             */
502            @Override
503            public List<DDMStructure> getStructures(long[] groupIds, long classNameId) {
504                    return ddmStructurePersistence.filterFindByG_C(groupIds, classNameId);
505            }
506    
507            @Override
508            public List<DDMStructure> getStructures(
509                    long[] groupIds, long classNameId, int start, int end) {
510    
511                    return ddmStructurePersistence.filterFindByG_C(
512                            groupIds, classNameId, start, end);
513            }
514    
515            @Override
516            public void revertStructure(
517                            long structureId, String version, ServiceContext serviceContext)
518                    throws PortalException {
519    
520                    DDMStructurePermission.check(
521                            getPermissionChecker(), structureId, ActionKeys.UPDATE);
522    
523                    ddmStructureLocalService.revertStructure(
524                            getUserId(), structureId, version, serviceContext);
525            }
526    
527            /**
528             * Returns an ordered range of all the structures matching the groups and
529             * class name IDs, and matching the keywords in the structure names and
530             * descriptions.
531             *
532             * <p>
533             * Useful when paginating results. Returns a maximum of <code>end -
534             * start</code> instances. <code>start</code> and <code>end</code> are not
535             * primary keys, they are indexes in the result set. Thus, <code>0</code>
536             * refers to the first result in the set. Setting both <code>start</code>
537             * and <code>end</code> to {@link
538             * com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full
539             * result set.
540             * </p>
541             *
542             * @param  companyId the primary key of the structure's company
543             * @param  groupIds the primary keys of the groups
544             * @param  classNameId the primary key of the class name of the model the
545             *         structure is related to
546             * @param  keywords the keywords (space separated), which may occur in the
547             *         structure's name or description (optionally <code>null</code>)
548             * @param  start the lower bound of the range of structures to return
549             * @param  end the upper bound of the range of structures to return (not
550             *         inclusive)
551             * @param  orderByComparator the comparator to order the structures
552             *         (optionally <code>null</code>)
553             * @return the range of matching structures ordered by the comparator
554             */
555            @Override
556            public List<DDMStructure> search(
557                    long companyId, long[] groupIds, long classNameId, String keywords,
558                    int start, int end, OrderByComparator<DDMStructure> orderByComparator) {
559    
560                    return ddmStructureFinder.filterFindByKeywords(
561                            companyId, groupIds, classNameId, keywords, start, end,
562                            orderByComparator);
563            }
564    
565            /**
566             * Returns an ordered range of all the structures matching the groups, class
567             * name IDs, name keyword, description keyword, storage type, and type.
568             *
569             * <p>
570             * Useful when paginating results. Returns a maximum of <code>end -
571             * start</code> instances. <code>start</code> and <code>end</code> are not
572             * primary keys, they are indexes in the result set. Thus, <code>0</code>
573             * refers to the first result in the set. Setting both <code>start</code>
574             * and <code>end</code> to {@link
575             * com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full
576             * result set.
577             * </p>
578             *
579             * @param  companyId the primary key of the structure's company
580             * @param  groupIds the primary keys of the groups
581             * @param  classNameId the primary key of the class name of the model the
582             *         structure is related to
583             * @param  name the name keywords
584             * @param  description the description keywords
585             * @param  storageType the structure's storage type. It can be "xml" or
586             *         "expando". For more information, see {@link
587             *         com.liferay.portlet.dynamicdatamapping.storage.StorageType}.
588             * @param  type the structure's type. For more information, see {@link
589             *         com.liferay.portlet.dynamicdatamapping.model.DDMStructureConstants}.
590             * @param  andOperator whether every field must match its keywords, or just
591             *         one field
592             * @param  start the lower bound of the range of structures to return
593             * @param  end the upper bound of the range of structures to return (not
594             *         inclusive)
595             * @param  orderByComparator the comparator to order the structures
596             *         (optionally <code>null</code>)
597             * @return the range of matching structures ordered by the comparator
598             */
599            @Override
600            public List<DDMStructure> search(
601                    long companyId, long[] groupIds, long classNameId, String name,
602                    String description, String storageType, int type, boolean andOperator,
603                    int start, int end, OrderByComparator<DDMStructure> orderByComparator) {
604    
605                    return ddmStructureFinder.filterFindByC_G_C_N_D_S_T(
606                            companyId, groupIds, classNameId, name, description, storageType,
607                            type, andOperator, start, end, orderByComparator);
608            }
609    
610            /**
611             * Returns the number of structures matching the groups and class name IDs,
612             * and matching the keywords in the structure names and descriptions.
613             *
614             * @param  companyId the primary key of the structure's company
615             * @param  groupIds the primary keys of the groups
616             * @param  classNameId the primary key of the class name of the model the
617             *         structure is related to
618             * @param  keywords the keywords (space separated), which may occur in the
619             *         structure's name or description (optionally <code>null</code>)
620             * @return the number of matching structures
621             */
622            @Override
623            public int searchCount(
624                    long companyId, long[] groupIds, long classNameId, String keywords) {
625    
626                    return ddmStructureFinder.filterCountByKeywords(
627                            companyId, groupIds, classNameId, keywords);
628            }
629    
630            /**
631             * Returns the number of structures matching the groups, class name IDs,
632             * name keyword, description keyword, storage type, and type
633             *
634             * @param  companyId the primary key of the structure's company
635             * @param  groupIds the primary keys of the groups
636             * @param  classNameId the primary key of the class name of the model the
637             *         structure is related to
638             * @param  name the name keywords
639             * @param  description the description keywords
640             * @param  storageType the structure's storage type. It can be "xml" or
641             *         "expando". For more information, see {@link
642             *         com.liferay.portlet.dynamicdatamapping.storage.StorageType}.
643             * @param  type the structure's type. For more information, see {@link
644             *         com.liferay.portlet.dynamicdatamapping.model.DDMStructureConstants}.
645             * @param  andOperator whether every field must match its keywords, or just
646             *         one field
647             * @return the number of matching structures
648             */
649            @Override
650            public int searchCount(
651                    long companyId, long[] groupIds, long classNameId, String name,
652                    String description, String storageType, int type, boolean andOperator) {
653    
654                    return ddmStructureFinder.filterCountByC_G_C_N_D_S_T(
655                            companyId, groupIds, classNameId, name, description, storageType,
656                            type, andOperator);
657            }
658    
659            @Override
660            public DDMStructure updateStructure(
661                            long groupId, long parentStructureId, long classNameId,
662                            String structureKey, Map<Locale, String> nameMap,
663                            Map<Locale, String> descriptionMap, DDMForm ddmForm,
664                            DDMFormLayout ddmFormLayout, ServiceContext serviceContext)
665                    throws PortalException {
666    
667                    DDMStructurePermission.check(
668                            getPermissionChecker(), groupId, classNameId, structureKey,
669                            ActionKeys.UPDATE);
670    
671                    return ddmStructureLocalService.updateStructure(
672                            getUserId(), groupId, parentStructureId, classNameId, structureKey,
673                            nameMap, descriptionMap, ddmForm, ddmFormLayout, serviceContext);
674            }
675    
676            /**
677             * Updates the structure matching the class name ID, structure key, and
678             * group, replacing its old parent structure, name map, description map, and
679             * XSD with new ones.
680             *
681             * @param      groupId the primary key of the group
682             * @param      parentStructureId the primary key of the new parent structure
683             * @param      classNameId the primary key of the class name for the
684             *             structure's related model
685             * @param      structureKey the unique string identifying the structure
686             * @param      nameMap the structure's new locales and localized names
687             * @param      descriptionMap the structure's new locales and localized
688             *             description
689             * @param      definition the structure's new XML schema definition
690             * @param      serviceContext the service context to be applied. Can set the
691             *             modification date.
692             * @return     the updated structure
693             * @throws     PortalException if the user did not have permission to update
694             *             the structure or if a portal exception occurred
695             * @deprecated As of 7.0.0, replaced by {@link #updateStructure(long, long,
696             *             long, String, Map, Map, DDMForm, DDMFormLayout,
697             *             ServiceContext)}
698             */
699            @Deprecated
700            @Override
701            public DDMStructure updateStructure(
702                            long groupId, long parentStructureId, long classNameId,
703                            String structureKey, Map<Locale, String> nameMap,
704                            Map<Locale, String> descriptionMap, String definition,
705                            ServiceContext serviceContext)
706                    throws PortalException {
707    
708                    DDMStructurePermission.check(
709                            getPermissionChecker(), groupId, classNameId, structureKey,
710                            ActionKeys.UPDATE);
711    
712                    return ddmStructureLocalService.updateStructure(
713                            groupId, parentStructureId, classNameId, structureKey, nameMap,
714                            descriptionMap, definition, serviceContext);
715            }
716    
717            @Override
718            public DDMStructure updateStructure(
719                            long structureId, long parentStructureId,
720                            Map<Locale, String> nameMap, Map<Locale, String> descriptionMap,
721                            DDMForm ddmForm, DDMFormLayout ddmFormLayout,
722                            ServiceContext serviceContext)
723                    throws PortalException {
724    
725                    DDMStructurePermission.check(
726                            getPermissionChecker(), structureId, ActionKeys.UPDATE);
727    
728                    return ddmStructureLocalService.updateStructure(
729                            getUserId(), structureId, parentStructureId, nameMap,
730                            descriptionMap, ddmForm, ddmFormLayout, serviceContext);
731            }
732    
733            /**
734             * Updates the structure matching the structure ID, replacing the old parent
735             * structure ID, name map, description map, and XSD with the new values.
736             *
737             * @param      structureId the primary key of the structure
738             * @param      parentStructureId the new parent structure primary key
739             * @param      nameMap the structure's new locales and localized names
740             * @param      descriptionMap the structure's new locales and localized
741             *             description
742             * @param      definition the new XML schema definition of the structure
743             * @param      serviceContext the service context to be applied. Can set the
744             *             modification date.
745             * @return     the updated structure
746             * @throws     PortalException if the user did not have permission to update
747             *             the structure or if a portal exception occurred
748             * @deprecated As of 7.0.0, replaced by {@link #updateStructure(long, long,
749             *             Map, Map, DDMForm, DDMFormLayout, ServiceContext)}
750             */
751            @Deprecated
752            @Override
753            public DDMStructure updateStructure(
754                            long structureId, long parentStructureId,
755                            Map<Locale, String> nameMap, Map<Locale, String> descriptionMap,
756                            String definition, ServiceContext serviceContext)
757                    throws PortalException {
758    
759                    DDMStructurePermission.check(
760                            getPermissionChecker(), structureId, ActionKeys.UPDATE);
761    
762                    return ddmStructureLocalService.updateStructure(
763                            structureId, parentStructureId, nameMap, descriptionMap, definition,
764                            serviceContext);
765            }
766    
767    }