001
014
015 package com.liferay.portlet.documentlibrary.service.impl;
016
017 import com.liferay.portal.kernel.exception.PortalException;
018 import com.liferay.portal.kernel.exception.SystemException;
019 import com.liferay.portal.kernel.systemevent.SystemEvent;
020 import com.liferay.portal.kernel.util.ArrayUtil;
021 import com.liferay.portal.kernel.util.LocaleUtil;
022 import com.liferay.portal.kernel.util.OrderByComparator;
023 import com.liferay.portal.kernel.util.ParamUtil;
024 import com.liferay.portal.kernel.util.SortedArrayList;
025 import com.liferay.portal.kernel.util.StringUtil;
026 import com.liferay.portal.kernel.util.Validator;
027 import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
028 import com.liferay.portal.model.SystemEventConstants;
029 import com.liferay.portal.model.User;
030 import com.liferay.portal.service.ServiceContext;
031 import com.liferay.portal.util.PortalUtil;
032 import com.liferay.portlet.documentlibrary.DuplicateFileEntryTypeException;
033 import com.liferay.portlet.documentlibrary.NoSuchFolderException;
034 import com.liferay.portlet.documentlibrary.NoSuchMetadataSetException;
035 import com.liferay.portlet.documentlibrary.model.DLFileEntry;
036 import com.liferay.portlet.documentlibrary.model.DLFileEntryMetadata;
037 import com.liferay.portlet.documentlibrary.model.DLFileEntryType;
038 import com.liferay.portlet.documentlibrary.model.DLFileEntryTypeConstants;
039 import com.liferay.portlet.documentlibrary.model.DLFileVersion;
040 import com.liferay.portlet.documentlibrary.model.DLFolder;
041 import com.liferay.portlet.documentlibrary.model.DLFolderConstants;
042 import com.liferay.portlet.documentlibrary.service.base.DLFileEntryTypeLocalServiceBaseImpl;
043 import com.liferay.portlet.documentlibrary.util.DLUtil;
044 import com.liferay.portlet.dynamicdatamapping.RequiredStructureException;
045 import com.liferay.portlet.dynamicdatamapping.StructureXsdException;
046 import com.liferay.portlet.dynamicdatamapping.model.DDMStructure;
047 import com.liferay.portlet.dynamicdatamapping.model.DDMStructureConstants;
048
049 import java.util.ArrayList;
050 import java.util.Date;
051 import java.util.HashMap;
052 import java.util.List;
053 import java.util.Locale;
054 import java.util.Map;
055
056
063 public class DLFileEntryTypeLocalServiceImpl
064 extends DLFileEntryTypeLocalServiceBaseImpl {
065
066 @Override
067 public DLFileEntryType addFileEntryType(
068 long userId, long groupId, String fileEntryTypeKey,
069 Map<Locale, String> nameMap, Map<Locale, String> descriptionMap,
070 long[] ddmStructureIds, ServiceContext serviceContext)
071 throws PortalException, SystemException {
072
073 User user = userPersistence.findByPrimaryKey(userId);
074
075 if (Validator.isNull(fileEntryTypeKey)) {
076 fileEntryTypeKey = String.valueOf(counterLocalService.increment());
077 }
078 else {
079 fileEntryTypeKey = StringUtil.toUpperCase(fileEntryTypeKey.trim());
080 }
081
082 String fileEntryTypeUuid = serviceContext.getUuid();
083
084 if (Validator.isNull(fileEntryTypeUuid)) {
085 fileEntryTypeUuid = PortalUUIDUtil.generate();
086 }
087
088 long fileEntryTypeId = counterLocalService.increment();
089
090 long ddmStructureId = updateDDMStructure(
091 userId, fileEntryTypeUuid, fileEntryTypeId, groupId, nameMap,
092 descriptionMap, serviceContext);
093
094 if (ddmStructureId > 0) {
095 ddmStructureIds = ArrayUtil.append(ddmStructureIds, ddmStructureId);
096 }
097
098 Date now = new Date();
099
100 validate(fileEntryTypeId, groupId, fileEntryTypeKey, ddmStructureIds);
101
102 DLFileEntryType dlFileEntryType = dlFileEntryTypePersistence.create(
103 fileEntryTypeId);
104
105 dlFileEntryType.setUuid(fileEntryTypeUuid);
106 dlFileEntryType.setGroupId(groupId);
107 dlFileEntryType.setCompanyId(user.getCompanyId());
108 dlFileEntryType.setUserId(user.getUserId());
109 dlFileEntryType.setUserName(user.getFullName());
110 dlFileEntryType.setCreateDate(serviceContext.getCreateDate(now));
111 dlFileEntryType.setModifiedDate(serviceContext.getModifiedDate(now));
112 dlFileEntryType.setFileEntryTypeKey(fileEntryTypeKey);
113 dlFileEntryType.setNameMap(nameMap);
114 dlFileEntryType.setDescriptionMap(descriptionMap);
115
116 dlFileEntryTypePersistence.update(dlFileEntryType);
117
118 dlFileEntryTypePersistence.addDDMStructures(
119 fileEntryTypeId, ddmStructureIds);
120
121 if (serviceContext.isAddGroupPermissions() ||
122 serviceContext.isAddGuestPermissions()) {
123
124 addFileEntryTypeResources(
125 dlFileEntryType, serviceContext.isAddGroupPermissions(),
126 serviceContext.isAddGuestPermissions());
127 }
128 else {
129 addFileEntryTypeResources(
130 dlFileEntryType, serviceContext.getGroupPermissions(),
131 serviceContext.getGuestPermissions());
132 }
133
134 return dlFileEntryType;
135 }
136
137 @Override
138 public DLFileEntryType addFileEntryType(
139 long userId, long groupId, String name, String description,
140 long[] ddmStructureIds, ServiceContext serviceContext)
141 throws PortalException, SystemException {
142
143 Map<Locale, String> nameMap = new HashMap<Locale, String>();
144
145 nameMap.put(LocaleUtil.getSiteDefault(), name);
146
147 Map<Locale, String> descriptionMap = new HashMap<Locale, String>();
148
149 descriptionMap.put(LocaleUtil.getSiteDefault(), description);
150
151 return addFileEntryType(
152 userId, groupId, null, nameMap, descriptionMap, ddmStructureIds,
153 serviceContext);
154 }
155
156 @Override
157 public void cascadeFileEntryTypes(long userId, DLFolder dlFolder)
158 throws PortalException, SystemException {
159
160 List<DLFileEntryType> dlFileEntryTypes = getFolderFileEntryTypes(
161 new long[] {dlFolder.getGroupId()}, dlFolder.getFolderId(), true);
162
163 List<Long> fileEntryTypeIds = getFileEntryTypeIds(dlFileEntryTypes);
164
165 long defaultFileEntryTypeId = getDefaultFileEntryTypeId(
166 dlFolder.getFolderId());
167
168 ServiceContext serviceContext = new ServiceContext();
169
170 serviceContext.setCompanyId(dlFolder.getCompanyId());
171 serviceContext.setScopeGroupId(dlFolder.getGroupId());
172 serviceContext.setUserId(userId);
173
174 cascadeFileEntryTypes(
175 userId, dlFolder.getGroupId(), dlFolder.getFolderId(),
176 defaultFileEntryTypeId, fileEntryTypeIds, serviceContext);
177 }
178
179 @Override
180 @SystemEvent(
181 action = SystemEventConstants.ACTION_SKIP,
182 type = SystemEventConstants.TYPE_DELETE)
183 public void deleteFileEntryType(DLFileEntryType dlFileEntryType)
184 throws PortalException, SystemException {
185
186 if (dlFileEntryPersistence.countByFileEntryTypeId(
187 dlFileEntryType.getFileEntryTypeId()) > 0) {
188
189 throw new RequiredStructureException(
190 RequiredStructureException.REFERENCED_STRUCTURE);
191 }
192
193 DDMStructure ddmStructure = ddmStructureLocalService.fetchStructure(
194 dlFileEntryType.getGroupId(),
195 PortalUtil.getClassNameId(DLFileEntryMetadata.class),
196 DLUtil.getDDMStructureKey(dlFileEntryType));
197
198 if (ddmStructure == null) {
199 ddmStructure = ddmStructureLocalService.fetchStructure(
200 dlFileEntryType.getGroupId(),
201 PortalUtil.getClassNameId(DLFileEntryMetadata.class),
202 DLUtil.getDeprecatedDDMStructureKey(dlFileEntryType));
203 }
204
205 if (ddmStructure != null) {
206 ddmStructureLocalService.deleteStructure(
207 ddmStructure.getStructureId());
208 }
209
210 dlFileEntryTypePersistence.remove(dlFileEntryType);
211 }
212
213 @Override
214 public void deleteFileEntryType(long fileEntryTypeId)
215 throws PortalException, SystemException {
216
217 DLFileEntryType dlFileEntryType =
218 dlFileEntryTypePersistence.findByPrimaryKey(fileEntryTypeId);
219
220 deleteFileEntryType(dlFileEntryType);
221 }
222
223 @Override
224 public void deleteFileEntryTypes(long groupId)
225 throws PortalException, SystemException {
226
227 List<DLFileEntryType> dlFileEntryTypes =
228 dlFileEntryTypePersistence.findByGroupId(groupId);
229
230 for (DLFileEntryType dlFileEntryType : dlFileEntryTypes) {
231 deleteFileEntryType(dlFileEntryType);
232 }
233 }
234
235 @Override
236 public DLFileEntryType fetchFileEntryType(long fileEntryTypeId)
237 throws SystemException {
238
239 return dlFileEntryTypePersistence.fetchByPrimaryKey(fileEntryTypeId);
240 }
241
242 @Override
243 public long getDefaultFileEntryTypeId(long folderId)
244 throws PortalException, SystemException {
245
246 folderId = getFileEntryTypesPrimaryFolderId(folderId);
247
248 if (folderId != DLFolderConstants.DEFAULT_PARENT_FOLDER_ID) {
249 DLFolder dlFolder = dlFolderPersistence.findByPrimaryKey(folderId);
250
251 return dlFolder.getDefaultFileEntryTypeId();
252 }
253 else {
254 return 0;
255 }
256 }
257
258 @Override
259 public DLFileEntryType getFileEntryType(long fileEntryTypeId)
260 throws PortalException, SystemException {
261
262 return dlFileEntryTypePersistence.findByPrimaryKey(fileEntryTypeId);
263 }
264
265 @Override
266 public DLFileEntryType getFileEntryType(
267 long groupId, String fileEntryTypeKey)
268 throws PortalException, SystemException {
269
270 fileEntryTypeKey = StringUtil.toUpperCase(fileEntryTypeKey.trim());
271
272 return dlFileEntryTypePersistence.findByG_F(groupId, fileEntryTypeKey);
273 }
274
275 @Override
276 public List<DLFileEntryType> getFileEntryTypes(long[] groupIds)
277 throws SystemException {
278
279 return dlFileEntryTypePersistence.findByGroupId(groupIds);
280 }
281
282 @Override
283 public List<DLFileEntryType> getFolderFileEntryTypes(
284 long[] groupIds, long folderId, boolean inherited)
285 throws PortalException, SystemException {
286
287 if (!inherited) {
288 return dlFolderPersistence.getDLFileEntryTypes(folderId);
289 }
290
291 List<DLFileEntryType> dlFileEntryTypes = null;
292
293 folderId = getFileEntryTypesPrimaryFolderId(folderId);
294
295 if (folderId != DLFolderConstants.DEFAULT_PARENT_FOLDER_ID) {
296 dlFileEntryTypes = dlFolderPersistence.getDLFileEntryTypes(
297 folderId);
298 }
299 else {
300 dlFileEntryTypes = new ArrayList<DLFileEntryType>(
301 getFileEntryTypes(groupIds));
302
303 DLFileEntryType dlFileEntryType =
304 dlFileEntryTypePersistence.fetchByPrimaryKey(
305 DLFileEntryTypeConstants.FILE_ENTRY_TYPE_ID_BASIC_DOCUMENT);
306
307 dlFileEntryTypes.add(0, dlFileEntryType);
308 }
309
310 return dlFileEntryTypes;
311 }
312
313 @Override
314 public List<DLFileEntryType> search(
315 long companyId, long[] groupIds, String keywords,
316 boolean includeBasicFileEntryType, int start, int end,
317 OrderByComparator orderByComparator)
318 throws SystemException {
319
320 return dlFileEntryTypeFinder.findByKeywords(
321 companyId, groupIds, keywords, includeBasicFileEntryType, start,
322 end, orderByComparator);
323 }
324
325 @Override
326 public int searchCount(
327 long companyId, long[] groupIds, String keywords,
328 boolean includeBasicFileEntryType)
329 throws SystemException {
330
331 return dlFileEntryTypeFinder.countByKeywords(
332 companyId, groupIds, keywords, includeBasicFileEntryType);
333 }
334
335 @Override
336 public void unsetFolderFileEntryTypes(long folderId)
337 throws SystemException {
338
339 List<DLFileEntryType> dlFileEntryTypes =
340 dlFolderPersistence.getDLFileEntryTypes(folderId);
341
342 for (DLFileEntryType dlFileEntryType : dlFileEntryTypes) {
343 dlFolderPersistence.removeDLFileEntryType(
344 folderId, dlFileEntryType);
345 }
346 }
347
348 @Override
349 public DLFileEntry updateFileEntryFileEntryType(
350 DLFileEntry dlFileEntry, ServiceContext serviceContext)
351 throws PortalException, SystemException {
352
353 long groupId = serviceContext.getScopeGroupId();
354 long folderId = DLFolderConstants.DEFAULT_PARENT_FOLDER_ID;
355
356 DLFolder dlFolder = dlFolderPersistence.fetchByPrimaryKey(
357 dlFileEntry.getFolderId());
358
359 if (dlFolder != null) {
360 groupId = dlFolder.getGroupId();
361 folderId = dlFolder.getFolderId();
362 }
363
364 List<DLFileEntryType> dlFileEntryTypes = getFolderFileEntryTypes(
365 PortalUtil.getSiteAndCompanyGroupIds(groupId), folderId, true);
366
367 List<Long> fileEntryTypeIds = getFileEntryTypeIds(dlFileEntryTypes);
368
369 if (fileEntryTypeIds.contains(dlFileEntry.getFileEntryTypeId())) {
370 return dlFileEntry;
371 }
372
373 long defaultFileEntryTypeId = getDefaultFileEntryTypeId(folderId);
374
375 DLFileVersion dlFileVersion =
376 dlFileVersionLocalService.getLatestFileVersion(
377 dlFileEntry.getFileEntryId(), true);
378
379 if (dlFileVersion.isPending()) {
380 workflowInstanceLinkLocalService.deleteWorkflowInstanceLink(
381 dlFileVersion.getCompanyId(), dlFileEntry.getGroupId(),
382 DLFileEntry.class.getName(), dlFileVersion.getFileVersionId());
383 }
384
385 return dlFileEntryLocalService.updateFileEntry(
386 serviceContext.getUserId(), dlFileEntry.getFileEntryId(), null,
387 null, null, null, null, false, defaultFileEntryTypeId, null, null,
388 null, 0, serviceContext);
389 }
390
391 @Override
392 public void updateFileEntryType(
393 long userId, long fileEntryTypeId, Map<Locale, String> nameMap,
394 Map<Locale, String> descriptionMap, long[] ddmStructureIds,
395 ServiceContext serviceContext)
396 throws PortalException, SystemException {
397
398 DLFileEntryType dlFileEntryType =
399 dlFileEntryTypePersistence.findByPrimaryKey(fileEntryTypeId);
400
401 long ddmStructureId = updateDDMStructure(
402 userId, dlFileEntryType.getUuid(), fileEntryTypeId,
403 dlFileEntryType.getGroupId(), nameMap, descriptionMap,
404 serviceContext);
405
406 if (ddmStructureId > 0) {
407 ddmStructureIds = ArrayUtil.append(ddmStructureIds, ddmStructureId);
408 }
409
410 dlFileEntryType.setModifiedDate(serviceContext.getModifiedDate(null));
411 dlFileEntryType.setNameMap(nameMap);
412 dlFileEntryType.setDescriptionMap(descriptionMap);
413
414 dlFileEntryTypePersistence.update(dlFileEntryType);
415
416 dlFileEntryTypePersistence.setDDMStructures(
417 fileEntryTypeId, ddmStructureIds);
418 }
419
420 @Override
421 public void updateFileEntryType(
422 long userId, long fileEntryTypeId, String name, String description,
423 long[] ddmStructureIds, ServiceContext serviceContext)
424 throws PortalException, SystemException {
425
426 Map<Locale, String> nameMap = new HashMap<Locale, String>();
427
428 nameMap.put(LocaleUtil.getSiteDefault(), name);
429
430 Map<Locale, String> descriptionMap = new HashMap<Locale, String>();
431
432 descriptionMap.put(LocaleUtil.getSiteDefault(), description);
433
434 updateFileEntryType(
435 userId, fileEntryTypeId, nameMap, descriptionMap, ddmStructureIds,
436 serviceContext);
437 }
438
439 @Override
440 public void updateFolderFileEntryTypes(
441 DLFolder dlFolder, List<Long> fileEntryTypeIds,
442 long defaultFileEntryTypeId, ServiceContext serviceContext)
443 throws PortalException, SystemException {
444
445 List<Long> originalFileEntryTypeIds = getFileEntryTypeIds(
446 dlFolderPersistence.getDLFileEntryTypes(dlFolder.getFolderId()));
447
448 if (fileEntryTypeIds.equals(originalFileEntryTypeIds)) {
449 return;
450 }
451
452 for (Long fileEntryTypeId : fileEntryTypeIds) {
453 if (!originalFileEntryTypeIds.contains(fileEntryTypeId)) {
454 dlFolderPersistence.addDLFileEntryType(
455 dlFolder.getFolderId(), fileEntryTypeId);
456 }
457 }
458
459 for (Long originalFileEntryTypeId : originalFileEntryTypeIds) {
460 if (!fileEntryTypeIds.contains(originalFileEntryTypeId)) {
461 dlFolderPersistence.removeDLFileEntryType(
462 dlFolder.getFolderId(), originalFileEntryTypeId);
463
464 workflowDefinitionLinkLocalService.deleteWorkflowDefinitionLink(
465 dlFolder.getCompanyId(), dlFolder.getGroupId(),
466 DLFolder.class.getName(), dlFolder.getFolderId(),
467 originalFileEntryTypeId);
468 }
469 }
470 }
471
472 protected void addFileEntryTypeResources(
473 DLFileEntryType dlFileEntryType, boolean addGroupPermissions,
474 boolean addGuestPermissions)
475 throws PortalException, SystemException {
476
477 resourceLocalService.addResources(
478 dlFileEntryType.getCompanyId(), dlFileEntryType.getGroupId(),
479 dlFileEntryType.getUserId(), DLFileEntryType.class.getName(),
480 dlFileEntryType.getFileEntryTypeId(), false, addGroupPermissions,
481 addGuestPermissions);
482 }
483
484 protected void addFileEntryTypeResources(
485 DLFileEntryType dlFileEntryType, String[] groupPermissions,
486 String[] guestPermissions)
487 throws PortalException, SystemException {
488
489 resourceLocalService.addModelResources(
490 dlFileEntryType.getCompanyId(), dlFileEntryType.getGroupId(),
491 dlFileEntryType.getUserId(), DLFileEntryType.class.getName(),
492 dlFileEntryType.getFileEntryTypeId(), groupPermissions,
493 guestPermissions);
494 }
495
496 protected void cascadeFileEntryTypes(
497 long userId, long groupId, long folderId,
498 long defaultFileEntryTypeId, List<Long> fileEntryTypeIds,
499 ServiceContext serviceContext)
500 throws PortalException, SystemException {
501
502 List<DLFileEntry> dlFileEntries = dlFileEntryPersistence.findByG_F(
503 groupId, folderId);
504
505 for (DLFileEntry dlFileEntry : dlFileEntries) {
506 Long fileEntryTypeId = dlFileEntry.getFileEntryTypeId();
507
508 if (fileEntryTypeIds.contains(fileEntryTypeId)) {
509 continue;
510 }
511
512 DLFileVersion dlFileVersion =
513 dlFileVersionLocalService.getLatestFileVersion(
514 dlFileEntry.getFileEntryId(), true);
515
516 if (dlFileVersion.isPending()) {
517 workflowInstanceLinkLocalService.deleteWorkflowInstanceLink(
518 dlFileVersion.getCompanyId(), groupId,
519 DLFileEntry.class.getName(),
520 dlFileVersion.getFileVersionId());
521 }
522
523 dlFileEntryLocalService.updateFileEntry(
524 userId, dlFileEntry.getFileEntryId(), null, null, null, null,
525 null, false, defaultFileEntryTypeId, null, null, null, 0,
526 serviceContext);
527 }
528
529 List<DLFolder> subFolders = dlFolderPersistence.findByG_M_P_H(
530 groupId, false, folderId, false);
531
532 for (DLFolder subFolder : subFolders) {
533 long subFolderId = subFolder.getFolderId();
534
535 if (subFolder.isOverrideFileEntryTypes()) {
536 continue;
537 }
538
539 cascadeFileEntryTypes(
540 userId, groupId, subFolderId, defaultFileEntryTypeId,
541 fileEntryTypeIds, serviceContext);
542 }
543 }
544
545 protected void fixDDMStructureKey(
546 String fileEntryTypeUuid, long fileEntryTypeId, long groupId)
547 throws SystemException {
548
549 DDMStructure ddmStructure = ddmStructureLocalService.fetchStructure(
550 groupId, PortalUtil.getClassNameId(DLFileEntryMetadata.class),
551 DLUtil.getDeprecatedDDMStructureKey(fileEntryTypeId));
552
553 if (ddmStructure != null) {
554 ddmStructure.setStructureKey(
555 DLUtil.getDDMStructureKey(fileEntryTypeUuid));
556
557 ddmStructureLocalService.updateDDMStructure(ddmStructure);
558 }
559 }
560
561 protected List<Long> getFileEntryTypeIds(
562 List<DLFileEntryType> dlFileEntryTypes) {
563
564 List<Long> fileEntryTypeIds = new SortedArrayList<Long>();
565
566 for (DLFileEntryType dlFileEntryType : dlFileEntryTypes) {
567 fileEntryTypeIds.add(dlFileEntryType.getFileEntryTypeId());
568 }
569
570 return fileEntryTypeIds;
571 }
572
573 protected long getFileEntryTypesPrimaryFolderId(long folderId)
574 throws NoSuchFolderException, SystemException {
575
576 while (folderId != DLFolderConstants.DEFAULT_PARENT_FOLDER_ID) {
577 DLFolder dlFolder = dlFolderPersistence.findByPrimaryKey(folderId);
578
579 if (dlFolder.isOverrideFileEntryTypes()) {
580 break;
581 }
582
583 folderId = dlFolder.getParentFolderId();
584 }
585
586 return folderId;
587 }
588
589 protected long updateDDMStructure(
590 long userId, String fileEntryTypeUuid, long fileEntryTypeId,
591 long groupId, Map<Locale, String> nameMap,
592 Map<Locale, String> descriptionMap, ServiceContext serviceContext)
593 throws PortalException, SystemException {
594
595 fixDDMStructureKey(fileEntryTypeUuid, fileEntryTypeId, groupId);
596
597 String ddmStructureKey = DLUtil.getDDMStructureKey(fileEntryTypeUuid);
598
599 String xsd = ParamUtil.getString(serviceContext, "xsd");
600
601 DDMStructure ddmStructure = ddmStructureLocalService.fetchStructure(
602 groupId, PortalUtil.getClassNameId(DLFileEntryMetadata.class),
603 ddmStructureKey);
604
605 if ((ddmStructure != null) && Validator.isNull(xsd)) {
606 xsd = ddmStructure.getXsd();
607 }
608
609 try {
610 if (ddmStructure == null) {
611 ddmStructure = ddmStructureLocalService.addStructure(
612 userId, groupId,
613 DDMStructureConstants.DEFAULT_PARENT_STRUCTURE_ID,
614 PortalUtil.getClassNameId(DLFileEntryMetadata.class),
615 ddmStructureKey, nameMap, descriptionMap, xsd, "xml",
616 DDMStructureConstants.TYPE_AUTO, serviceContext);
617 }
618 else {
619 ddmStructure = ddmStructureLocalService.updateStructure(
620 ddmStructure.getStructureId(),
621 ddmStructure.getParentStructureId(), nameMap,
622 descriptionMap, xsd, serviceContext);
623 }
624
625 return ddmStructure.getStructureId();
626 }
627 catch (StructureXsdException sxe) {
628 if (ddmStructure != null) {
629 ddmStructureLocalService.deleteStructure(
630 ddmStructure.getStructureId());
631 }
632 }
633
634 return 0;
635 }
636
637 protected void validate(
638 long fileEntryTypeId, long groupId, String fileEntryTypeKey,
639 long[] ddmStructureIds)
640 throws PortalException, SystemException {
641
642 DLFileEntryType dlFileEntryType = dlFileEntryTypePersistence.fetchByG_F(
643 groupId, fileEntryTypeKey);
644
645 if ((dlFileEntryType != null) &&
646 (dlFileEntryType.getFileEntryTypeId() != fileEntryTypeId)) {
647
648 throw new DuplicateFileEntryTypeException(fileEntryTypeKey);
649 }
650
651 if (ddmStructureIds.length == 0) {
652 throw new NoSuchMetadataSetException();
653 }
654
655 for (long ddmStructureId : ddmStructureIds) {
656 DDMStructure ddmStructure =
657 ddmStructurePersistence.fetchByPrimaryKey(ddmStructureId);
658
659 if (ddmStructure == null) {
660 throw new NoSuchMetadataSetException();
661 }
662 }
663 }
664
665 }