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