/** * Converts the soap model instance into a normal model instance. * * @param soapModel the soap model instance to convert * @return the normal model instance */ public static DLFolder toModel(DLFolderSoap soapModel) { if (soapModel == null) { return null; } DLFolder model = new DLFolderImpl(); model.setUuid(soapModel.getUuid()); model.setFolderId(soapModel.getFolderId()); model.setGroupId(soapModel.getGroupId()); model.setCompanyId(soapModel.getCompanyId()); model.setUserId(soapModel.getUserId()); model.setUserName(soapModel.getUserName()); model.setCreateDate(soapModel.getCreateDate()); model.setModifiedDate(soapModel.getModifiedDate()); model.setRepositoryId(soapModel.getRepositoryId()); model.setMountPoint(soapModel.getMountPoint()); model.setParentFolderId(soapModel.getParentFolderId()); model.setTreePath(soapModel.getTreePath()); model.setName(soapModel.getName()); model.setDescription(soapModel.getDescription()); model.setLastPostDate(soapModel.getLastPostDate()); model.setDefaultFileEntryTypeId(soapModel.getDefaultFileEntryTypeId()); model.setHidden(soapModel.getHidden()); model.setRestrictionType(soapModel.getRestrictionType()); model.setLastPublishDate(soapModel.getLastPublishDate()); model.setStatus(soapModel.getStatus()); model.setStatusByUserId(soapModel.getStatusByUserId()); model.setStatusByUserName(soapModel.getStatusByUserName()); model.setStatusDate(soapModel.getStatusDate()); return model; }
protected DLFolder addDLFolder() throws Exception { long pk = RandomTestUtil.nextLong(); DLFolder dlFolder = _persistence.create(pk); dlFolder.setUuid(RandomTestUtil.randomString()); dlFolder.setGroupId(RandomTestUtil.nextLong()); dlFolder.setCompanyId(RandomTestUtil.nextLong()); dlFolder.setUserId(RandomTestUtil.nextLong()); dlFolder.setUserName(RandomTestUtil.randomString()); dlFolder.setCreateDate(RandomTestUtil.nextDate()); dlFolder.setModifiedDate(RandomTestUtil.nextDate()); dlFolder.setRepositoryId(RandomTestUtil.nextLong()); dlFolder.setMountPoint(RandomTestUtil.randomBoolean()); dlFolder.setParentFolderId(RandomTestUtil.nextLong()); dlFolder.setTreePath(RandomTestUtil.randomString()); dlFolder.setName(RandomTestUtil.randomString()); dlFolder.setDescription(RandomTestUtil.randomString()); dlFolder.setLastPostDate(RandomTestUtil.nextDate()); dlFolder.setDefaultFileEntryTypeId(RandomTestUtil.nextLong()); dlFolder.setHidden(RandomTestUtil.randomBoolean()); dlFolder.setOverrideFileEntryTypes(RandomTestUtil.randomBoolean()); dlFolder.setStatus(RandomTestUtil.nextInt()); dlFolder.setStatusByUserId(RandomTestUtil.nextLong()); dlFolder.setStatusByUserName(RandomTestUtil.randomString()); dlFolder.setStatusDate(RandomTestUtil.nextDate()); _persistence.update(dlFolder); return dlFolder; }
@Test public void testUpdateExisting() throws Exception { long pk = ServiceTestUtil.nextLong(); DLFolder newDLFolder = _persistence.create(pk); newDLFolder.setUuid(ServiceTestUtil.randomString()); newDLFolder.setGroupId(ServiceTestUtil.nextLong()); newDLFolder.setCompanyId(ServiceTestUtil.nextLong()); newDLFolder.setUserId(ServiceTestUtil.nextLong()); newDLFolder.setUserName(ServiceTestUtil.randomString()); newDLFolder.setCreateDate(ServiceTestUtil.nextDate()); newDLFolder.setModifiedDate(ServiceTestUtil.nextDate()); newDLFolder.setRepositoryId(ServiceTestUtil.nextLong()); newDLFolder.setMountPoint(ServiceTestUtil.randomBoolean()); newDLFolder.setParentFolderId(ServiceTestUtil.nextLong()); newDLFolder.setName(ServiceTestUtil.randomString()); newDLFolder.setDescription(ServiceTestUtil.randomString()); newDLFolder.setLastPostDate(ServiceTestUtil.nextDate()); newDLFolder.setDefaultFileEntryTypeId(ServiceTestUtil.nextLong()); newDLFolder.setHidden(ServiceTestUtil.randomBoolean()); newDLFolder.setOverrideFileEntryTypes(ServiceTestUtil.randomBoolean()); newDLFolder.setStatus(ServiceTestUtil.nextInt()); newDLFolder.setStatusByUserId(ServiceTestUtil.nextLong()); newDLFolder.setStatusByUserName(ServiceTestUtil.randomString()); newDLFolder.setStatusDate(ServiceTestUtil.nextDate()); _persistence.update(newDLFolder); DLFolder existingDLFolder = _persistence.findByPrimaryKey(newDLFolder.getPrimaryKey()); Assert.assertEquals(existingDLFolder.getUuid(), newDLFolder.getUuid()); Assert.assertEquals(existingDLFolder.getFolderId(), newDLFolder.getFolderId()); Assert.assertEquals(existingDLFolder.getGroupId(), newDLFolder.getGroupId()); Assert.assertEquals(existingDLFolder.getCompanyId(), newDLFolder.getCompanyId()); Assert.assertEquals(existingDLFolder.getUserId(), newDLFolder.getUserId()); Assert.assertEquals(existingDLFolder.getUserName(), newDLFolder.getUserName()); Assert.assertEquals( Time.getShortTimestamp(existingDLFolder.getCreateDate()), Time.getShortTimestamp(newDLFolder.getCreateDate())); Assert.assertEquals( Time.getShortTimestamp(existingDLFolder.getModifiedDate()), Time.getShortTimestamp(newDLFolder.getModifiedDate())); Assert.assertEquals(existingDLFolder.getRepositoryId(), newDLFolder.getRepositoryId()); Assert.assertEquals(existingDLFolder.getMountPoint(), newDLFolder.getMountPoint()); Assert.assertEquals(existingDLFolder.getParentFolderId(), newDLFolder.getParentFolderId()); Assert.assertEquals(existingDLFolder.getName(), newDLFolder.getName()); Assert.assertEquals(existingDLFolder.getDescription(), newDLFolder.getDescription()); Assert.assertEquals( Time.getShortTimestamp(existingDLFolder.getLastPostDate()), Time.getShortTimestamp(newDLFolder.getLastPostDate())); Assert.assertEquals( existingDLFolder.getDefaultFileEntryTypeId(), newDLFolder.getDefaultFileEntryTypeId()); Assert.assertEquals(existingDLFolder.getHidden(), newDLFolder.getHidden()); Assert.assertEquals( existingDLFolder.getOverrideFileEntryTypes(), newDLFolder.getOverrideFileEntryTypes()); Assert.assertEquals(existingDLFolder.getStatus(), newDLFolder.getStatus()); Assert.assertEquals(existingDLFolder.getStatusByUserId(), newDLFolder.getStatusByUserId()); Assert.assertEquals(existingDLFolder.getStatusByUserName(), newDLFolder.getStatusByUserName()); Assert.assertEquals( Time.getShortTimestamp(existingDLFolder.getStatusDate()), Time.getShortTimestamp(newDLFolder.getStatusDate())); }
public DLFolder updateStatus( long userId, long folderId, int status, Map<String, Serializable> workflowContext, ServiceContext serviceContext) throws PortalException, SystemException { // Folder User user = userPersistence.findByPrimaryKey(userId); DLFolder dlFolder = dlFolderPersistence.findByPrimaryKey(folderId); int oldStatus = dlFolder.getStatus(); dlFolder.setStatus(status); dlFolder.setStatusByUserId(user.getUserId()); dlFolder.setStatusByUserName(user.getFullName()); dlFolder.setStatusDate(new Date()); dlFolderPersistence.update(dlFolder); // Folders, file entries, and file shortcuts QueryDefinition queryDefinition = new QueryDefinition(WorkflowConstants.STATUS_ANY); List<Object> foldersAndFileEntriesAndFileShortcuts = getFoldersAndFileEntriesAndFileShortcuts( dlFolder.getGroupId(), folderId, null, false, queryDefinition); dlAppHelperLocalService.updateDependentStatus( user, foldersAndFileEntriesAndFileShortcuts, status); // Asset if (status == WorkflowConstants.STATUS_APPROVED) { assetEntryLocalService.updateVisible(DLFolder.class.getName(), dlFolder.getFolderId(), true); } else if (status == WorkflowConstants.STATUS_IN_TRASH) { assetEntryLocalService.updateVisible(DLFolder.class.getName(), dlFolder.getFolderId(), false); } // Trash if (status == WorkflowConstants.STATUS_IN_TRASH) { UnicodeProperties typeSettingsProperties = new UnicodeProperties(); typeSettingsProperties.put("title", dlFolder.getName()); trashEntryLocalService.addTrashEntry( userId, dlFolder.getGroupId(), DLFolderConstants.getClassName(), dlFolder.getFolderId(), WorkflowConstants.STATUS_APPROVED, null, typeSettingsProperties); } else { trashEntryLocalService.deleteEntry(DLFolderConstants.getClassName(), dlFolder.getFolderId()); } // Indexer if (((status == WorkflowConstants.STATUS_APPROVED) || (status == WorkflowConstants.STATUS_IN_TRASH) || (oldStatus == WorkflowConstants.STATUS_IN_TRASH)) && ((serviceContext == null) || serviceContext.isIndexingEnabled())) { Indexer indexer = IndexerRegistryUtil.nullSafeGetIndexer(DLFolderConstants.getClassName()); indexer.reindex(dlFolder); } return dlFolder; }