List of usage examples for com.liferay.portal.kernel.search IndexerRegistryUtil nullSafeGetIndexer
public static <T> Indexer<T> nullSafeGetIndexer(String className)
From source file:at.meduni.liferay.portlet.bbmrieric.service.impl.D2BiobankLocalServiceImpl.java
License:Open Source License
/** * //w ww .j a va 2 s . co m * @param biobankId * @param serviceContext * @return */ public D2Biobank addD2Biobank(long biobankId, long companyId, long groupId, long userId, String biobankName, String ldapbiobankID, String ldapupdateuuid, String contactIDRef, long contactPriority, String biobankJurisdicalPerson, String biobankCountry, boolean biobankPartnerCharterSigned, String bioresourceReference, String biobankNetworkIDRef, String geoLatitude, String geoLongitude, boolean collaborationPartnersCommercial, boolean collaborationPartnersNonforprofit, boolean biobankITSupportAvailable, long biobankITStaffSize, boolean biobankISAvailable, boolean biobankHISAvailable, String biobankAcronym, String biobankDescription, String biobankURL, String biobankHeadFirstName, String biobankHeadLastName, String biobankHeadRole, boolean biobankClinical, boolean biobankPopulation, boolean biobankResearchStudy, boolean biobankNonHuman, boolean biobankCollection, String biobankType, ServiceContext serviceContext) { try { // Create the Biobank Entry // Set Primary Key if (biobankId == 0) { biobankId = counterLocalService.increment(); } D2Biobank d2biobank = d2BiobankPersistence.create(biobankId); // Set provenance fields if (companyId == 0) { companyId = serviceContext.getCompanyId(); } if (groupId == 0) { groupId = serviceContext.getScopeGroupId(); } if (userId == 0) { userId = serviceContext.getUserId(); } Date now = new Date(); d2biobank.setCreateDate(serviceContext.getCreateDate(now)); d2biobank.setModifiedDate(serviceContext.getModifiedDate(now)); d2biobank.setUserId(userId); d2biobank.setGroupId(groupId); d2biobank.setCompanyId(companyId); // Set mandatory fields d2biobank.setBiobankName(biobankName); d2biobank.setBbmribiobankID(ldapbiobankID); d2biobank.setUpdateuuid(ldapupdateuuid); d2biobank.setContactIDRef(contactIDRef); d2biobank.setContactPriority(contactPriority); d2biobank.setBiobankJurisdicalPerson(biobankJurisdicalPerson); d2biobank.setBiobankCountry(biobankCountry.toUpperCase()); d2biobank.setBiobankPartnerCharterSigned(biobankPartnerCharterSigned); // Set optional fields d2biobank.setBioresourceReference(bioresourceReference); d2biobank.setBiobankNetworkIDRef(biobankNetworkIDRef); d2biobank.setGeoLatitude(geoLatitude); d2biobank.setGeoLongitude(geoLongitude); d2biobank.setCollaborationPartnersCommercial(collaborationPartnersCommercial); d2biobank.setCollaborationPartnersNonforprofit(collaborationPartnersNonforprofit); d2biobank.setBiobankITSupportAvailable(biobankITSupportAvailable); d2biobank.setBiobankITStaffSize(biobankITStaffSize); d2biobank.setBiobankISAvailable(biobankISAvailable); d2biobank.setBiobankHISAvailable(biobankHISAvailable); d2biobank.setBiobankAcronym(biobankAcronym); d2biobank.setBiobankDescription(biobankDescription); d2biobank.setBiobankURL(biobankURL); d2biobank.setBiobankHeadFirstName(biobankHeadFirstName); d2biobank.setBiobankHeadLastName(biobankHeadLastName); d2biobank.setBiobankHeadRole(biobankHeadRole); d2biobank.setBiobankClinical(biobankClinical); d2biobank.setBiobankPopulation(biobankPopulation); d2biobank.setBiobankResearchStudy(biobankResearchStudy); d2biobank.setBiobankNonHuman(biobankNonHuman); d2biobank.setBiobankCollection(biobankCollection); d2biobank.setBiobankType(biobankType); // Liferay Expension Fields d2biobank.setExpandoBridgeAttributes(serviceContext); d2BiobankPersistence.update(d2biobank); // Add Asset Entry to Liferay resourceLocalService.addResources(companyId, groupId, userId, D2Biobank.class.getName(), biobankId, false, true, true); AssetEntry assetEntry = assetEntryLocalService.updateEntry(userId, groupId, d2biobank.getCreateDate(), d2biobank.getModifiedDate(), D2Biobank.class.getName(), d2biobank.getBiobankId(), d2biobank.getUuid(), 0, serviceContext.getAssetCategoryIds(), serviceContext.getAssetTagNames(), true, null, null, null, ContentTypes.TEXT_HTML, d2biobank.getBiobankName(), d2biobank.getBiobankDescription(), null, null, null, 0, 0, null, false); //updateEntry(userId, groupId, createDate, modifiedDate, className, classPK, classUuid, classTypeId=0, categoryIds, tagNames, visible, startDate, endDate, expirationDate, mimeType, title, description, summary, url, layoutUuid, height, width, priority, sync) assetLinkLocalService.updateLinks(userId, assetEntry.getEntryId(), serviceContext.getAssetLinkEntryIds(), AssetLinkConstants.TYPE_RELATED); Indexer indexer = IndexerRegistryUtil.nullSafeGetIndexer(D2Biobank.class); indexer.reindex(d2biobank); return d2biobank; } catch (Exception e) { System.out.println("[" + date_format_apache_error.format(new Date()) + "] [error] [BBMRIERICDatabase-portlet::at.meduni.liferay.portlet.bbmrieric.service.impl.D2BiobankLocalServiceImpl::addD2Biobank] Error creating D2Biobank with (D2Biobank newbiobank, ServiceContext serviceContext)."); e.printStackTrace(); } return null; }
From source file:at.meduni.liferay.portlet.bbmrieric.service.impl.D2BiobankLocalServiceImpl.java
License:Open Source License
/** * //ww w . j a v a2 s . c o m * @param newbiobank * @param serviceContext * @return */ public D2Biobank updateD2Biobank(D2Biobank d2biobank, ServiceContext serviceContext) { try { // Set provenance fields if (d2biobank.getUserId() == 0) { d2biobank.setUserId(serviceContext.getUserId()); } Date now = new Date(); d2biobank.setModifiedDate(serviceContext.getModifiedDate(now)); d2biobank.setBiobankCountry(d2biobank.getBiobankCountry().toUpperCase()); // Liferay Expension Fields d2biobank.setExpandoBridgeAttributes(serviceContext); d2BiobankPersistence.update(d2biobank); // Add Asset Entry to Liferay resourceLocalService.updateResources(d2biobank.getCompanyId(), d2biobank.getGroupId(), d2biobank.getBiobankName(), d2biobank.getBiobankId(), serviceContext.getGroupPermissions(), serviceContext.getGuestPermissions()); AssetEntry assetEntry = assetEntryLocalService.updateEntry(d2biobank.getUserId(), d2biobank.getGroupId(), d2biobank.getCreateDate(), d2biobank.getModifiedDate(), D2Biobank.class.getName(), d2biobank.getBiobankId(), d2biobank.getUuid(), 0, serviceContext.getAssetCategoryIds(), serviceContext.getAssetTagNames(), true, null, null, null, ContentTypes.TEXT_HTML, d2biobank.getBiobankName(), d2biobank.getBiobankDescription(), null, null, null, 0, 0, null, false); //updateEntry(userId, groupId, createDate, modifiedDate, className, classPK, classUuid, classTypeId=0, categoryIds, tagNames, visible, startDate, endDate, expirationDate, mimeType, title, description, summary, url, layoutUuid, height, width, priority, sync) assetLinkLocalService.updateLinks(d2biobank.getUserId(), assetEntry.getEntryId(), serviceContext.getAssetLinkEntryIds(), AssetLinkConstants.TYPE_RELATED); Indexer indexer = IndexerRegistryUtil.nullSafeGetIndexer(D2Biobank.class); indexer.reindex(d2biobank); return d2biobank; } catch (Exception e) { System.out.println("[" + date_format_apache_error.format(new Date()) + "] [error] [BBMRIERICDatabase-portlet::at.meduni.liferay.portlet.bbmrieric.service.impl.D2BiobankLocalServiceImpl::updateD2Biobank] Error updateing D2Biobank with (D2Biobank newbiobank, ServiceContext serviceContext)."); e.printStackTrace(); } return null; }
From source file:at.meduni.liferay.portlet.bbmrieric.service.impl.D2BiobankLocalServiceImpl.java
License:Open Source License
/** * //from w w w. j av a2s . c o m * @param biobankId * @param serviceContext * @return */ public D2Biobank updateD2Biobank(long biobankId, long userId, String biobankName, String ldapbiobankID, String ldapupdateuuid, String contactIDRef, long contactPriority, String biobankJurisdicalPerson, String biobankCountry, boolean biobankPartnerCharterSigned, String bioresourceReference, String biobankNetworkIDRef, String geoLatitude, String geoLongitude, boolean collaborationPartnersCommercial, boolean collaborationPartnersNonforprofit, boolean biobankITSupportAvailable, long biobankITStaffSize, boolean biobankISAvailable, boolean biobankHISAvailable, String biobankAcronym, String biobankDescription, String biobankURL, String biobankHeadFirstName, String biobankHeadLastName, String biobankHeadRole, boolean biobankClinical, boolean biobankPopulation, boolean biobankResearchStudy, boolean biobankNonHuman, boolean biobankCollection, String biobankType, ServiceContext serviceContext) { try { // Update the Biobank Entry D2Biobank d2biobank = getD2Biobank(biobankId); // Set provenance fields if (userId == 0) { userId = serviceContext.getUserId(); } Date now = new Date(); d2biobank.setModifiedDate(serviceContext.getModifiedDate(now)); d2biobank.setUserId(userId); // Set mandatory fields d2biobank.setBiobankName(biobankName); d2biobank.setBbmribiobankID(ldapbiobankID); d2biobank.setUpdateuuid(ldapupdateuuid); d2biobank.setContactIDRef(contactIDRef); d2biobank.setContactPriority(contactPriority); d2biobank.setBiobankJurisdicalPerson(biobankJurisdicalPerson); if (biobankCountry.equalsIgnoreCase("ee")) { biobankCountry = "et"; } d2biobank.setBiobankCountry(biobankCountry); d2biobank.setBiobankPartnerCharterSigned(biobankPartnerCharterSigned); // Set optional fields d2biobank.setBioresourceReference(bioresourceReference); d2biobank.setBiobankNetworkIDRef(biobankNetworkIDRef); d2biobank.setGeoLatitude(geoLatitude); d2biobank.setGeoLongitude(geoLongitude); d2biobank.setCollaborationPartnersCommercial(collaborationPartnersCommercial); d2biobank.setCollaborationPartnersNonforprofit(collaborationPartnersNonforprofit); d2biobank.setBiobankITSupportAvailable(biobankITSupportAvailable); d2biobank.setBiobankITStaffSize(biobankITStaffSize); d2biobank.setBiobankISAvailable(biobankISAvailable); d2biobank.setBiobankHISAvailable(biobankHISAvailable); d2biobank.setBiobankAcronym(biobankAcronym); d2biobank.setBiobankDescription(biobankDescription); d2biobank.setBiobankURL(biobankURL); d2biobank.setBiobankHeadFirstName(biobankHeadFirstName); d2biobank.setBiobankHeadLastName(biobankHeadLastName); d2biobank.setBiobankHeadRole(biobankHeadRole); d2biobank.setBiobankClinical(biobankClinical); d2biobank.setBiobankPopulation(biobankPopulation); d2biobank.setBiobankResearchStudy(biobankResearchStudy); d2biobank.setBiobankNonHuman(biobankNonHuman); d2biobank.setBiobankCollection(biobankCollection); d2biobank.setBiobankType(biobankType); // Liferay Expension Fields d2biobank.setExpandoBridgeAttributes(serviceContext); d2BiobankPersistence.update(d2biobank); // Add Asset Entry to Liferay resourceLocalService.updateResources(d2biobank.getCompanyId(), d2biobank.getGroupId(), d2biobank.getBiobankName(), biobankId, serviceContext.getGroupPermissions(), serviceContext.getGuestPermissions()); AssetEntry assetEntry = assetEntryLocalService.updateEntry(userId, d2biobank.getGroupId(), d2biobank.getCreateDate(), d2biobank.getModifiedDate(), D2Biobank.class.getName(), d2biobank.getBiobankId(), d2biobank.getUuid(), 0, serviceContext.getAssetCategoryIds(), serviceContext.getAssetTagNames(), true, null, null, null, ContentTypes.TEXT_HTML, d2biobank.getBiobankName(), d2biobank.getBiobankDescription(), null, null, null, 0, 0, null, false); //updateEntry(userId, groupId, createDate, modifiedDate, className, classPK, classUuid, classTypeId=0, categoryIds, tagNames, visible, startDate, endDate, expirationDate, mimeType, title, description, summary, url, layoutUuid, height, width, priority, sync) assetLinkLocalService.updateLinks(userId, assetEntry.getEntryId(), serviceContext.getAssetLinkEntryIds(), AssetLinkConstants.TYPE_RELATED); Indexer indexer = IndexerRegistryUtil.nullSafeGetIndexer(D2Biobank.class); indexer.reindex(d2biobank); return d2biobank; } catch (Exception e) { System.out.println("[" + date_format_apache_error.format(new Date()) + "] [error] [BBMRIERICDatabase-portlet::at.meduni.liferay.portlet.bbmrieric.service.impl.D2BiobankLocalServiceImpl::updateD2Biobank] Error updateing D2Biobank with (D2Biobank newbiobank, ServiceContext serviceContext)."); e.printStackTrace(); } return null; }
From source file:at.meduni.liferay.portlet.bbmrieric.service.impl.D2BiobankLocalServiceImpl.java
License:Open Source License
/** * //from ww w. jav a 2 s.c om * @param biobankId * @param serviceContext * @return */ public D2Biobank deleteD2Biobank(long biobankId, ServiceContext serviceContext) { try { D2Biobank d2biobank = getD2Biobank(biobankId); resourceLocalService.deleteResource(serviceContext.getCompanyId(), D2Biobank.class.getName(), ResourceConstants.SCOPE_INDIVIDUAL, biobankId); AssetEntry assetEntry = assetEntryLocalService.fetchEntry(D2Biobank.class.getName(), biobankId); assetLinkLocalService.deleteLinks(assetEntry.getEntryId()); assetEntryLocalService.deleteEntry(assetEntry); Indexer indexer = IndexerRegistryUtil.nullSafeGetIndexer(D2Biobank.class); indexer.delete(d2biobank); d2biobank = deleteD2Biobank(d2biobank); return d2biobank; } catch (Exception e) { System.out.println("[" + date_format_apache_error.format(new Date()) + "] [error] [BBMRIERICDatabase-portlet::at.meduni.liferay.portlet.bbmrieric.service.impl.D2BiobankLocalServiceImpl::deleteD2Biobank] Error deleteing D2Biobank " + biobankId + "."); e.printStackTrace(); } return null; }
From source file:ca.efendi.datafeeds.service.impl.CJProductLocalServiceImpl.java
License:Open Source License
@Override @Indexable(type = IndexableType.REINDEX) public CJProduct refresh(final FtpSubscription subscription, final CJProduct newCJProduct) throws PortalException { final Date now = new Date(); CJProduct cjProduct;/*ww w. ja v a 2 s . c o m*/ try { cjProduct = cjProductPersistence.findByPROGRAM_CATALOG_SKU(newCJProduct.getProgramName(), newCJProduct.getCatalogName(), newCJProduct.getSku()); } catch (final NoSuchCJProductException e) { final long productId = counterLocalService.increment(CJProduct.class.getName()); cjProduct = cjProductPersistence.create(productId); resourceLocalService.addModelResources(subscription.getCompanyId(), subscription.getGroupId(), subscription.getUserId(), CJProduct.class.getName(), productId, new String[] { "VIEW" }, new String[] { "VIEW" }); cjProduct.setUuid(PortalUUIDUtil.generate()); cjProduct.setGroupId(subscription.getGroupId()); cjProduct.setCompanyId(subscription.getCompanyId()); cjProduct.setUserId(subscription.getUserId()); cjProduct.setUserName(subscription.getUserName()); cjProduct.setProgramName(newCJProduct.getProgramName()); cjProduct.setCatalogName(newCJProduct.getCatalogName()); cjProduct.setSku(newCJProduct.getSku()); // TODO: is it already implemented by Liferay? //cjProduct.setCreateDate(now); } cjProduct.setProgramUrl(newCJProduct.getProgramUrl()); cjProduct.setLastUpdated(newCJProduct.getLastUpdated()); cjProduct.setName(newCJProduct.getName()); cjProduct.setKeywords(newCJProduct.getKeywords()); cjProduct.setDescription(newCJProduct.getDescription()); cjProduct.setManufacturer(newCJProduct.getManufacturer()); cjProduct.setManufacturerId(newCJProduct.getManufacturerId()); cjProduct.setCurrency(newCJProduct.getCurrency()); cjProduct.setPrice(newCJProduct.getPrice()); cjProduct.setBuyUrl(newCJProduct.getBuyUrl()); cjProduct.setImpressionUrl(newCJProduct.getImpressionUrl()); cjProduct.setImageUrl(newCJProduct.getImageUrl()); cjProduct.setInStock(newCJProduct.getInStock()); // TODO: is it already implemented by Liferay? //cjProduct.setModifiedDate(now); //cjProduct.setCompanyId(COMPANY_ID); //cjProduct.setGroupId(GROUP_ID); //cjProduct.setUserId(USER_ID); Date current = new Date(); Calendar cal = Calendar.getInstance(); cal.add(Calendar.MONTH, 1); Date expire = cal.getTime(); /* assetEntryLocalService.updateEntry( cjProduct.getUserId(), cjProduct.getGroupId(), CJProduct.class.getName(), cjProduct.getProductId(), new long[]{}, //serviceContext.getAssetCategoryIds(), new String[]{"shopping"}); //serviceContext.getAssetTagNames()); assetEntryLocalService.updateEntry( CJProduct.class.getName(), cjProduct.getProductId(), current, expire, true, true); */ String summary = HtmlUtil.extractText(StringUtil.shorten(cjProduct.getDescription(), 500)); long[] assetCategoryIds = null; String[] assetTagNames = null; boolean visible = true; Double priority = null; AssetEntry assetEntry = assetEntryLocalService.updateEntry(cjProduct.getUserId(), cjProduct.getGroupId(), cjProduct.getCreateDate(), cjProduct.getModifiedDate(), CJProduct.class.getName(), cjProduct.getProductId(), cjProduct.getUuid(), 0, assetCategoryIds, assetTagNames, true, visible, current, expire, current, expire, ContentTypes.TEXT_HTML, cjProduct.getName(), cjProduct.getDescription(), summary, cjProduct.getBuyUrl(), null, 0, 0, priority); long[] assetLinkEntryIds = null; assetLinkLocalService.updateLinks(cjProduct.getUserId(), assetEntry.getEntryId(), assetLinkEntryIds, AssetLinkConstants.TYPE_RELATED); Indexer<CJProduct> indexer = IndexerRegistryUtil.nullSafeGetIndexer(CJProduct.class); indexer.reindex(cjProduct); return cjProductPersistence.update(cjProduct); }
From source file:com.idetronic.subur.service.impl.AuthorLocalServiceImpl.java
License:Open Source License
public long addAuthor(String firstName, String middleName, String lastName, String salutation, String email, String officeNo, Map<String, String> authorSite, String remoteId, int idType, long userId, long groupId, long createdByUserId, String[] expertiseNames, String[] researchInterestNames, ServiceContext serviceContext) throws SystemException, PortalException, IOException { User user = userLocalService.getUserById(userId); Date now = new Date(); long authorId = CounterLocalServiceUtil.increment(Author.class.getName()); Author author = authorPersistence.create(authorId); author.setFirstName(firstName);//from w w w .j av a 2s .c o m author.setMiddleName(middleName); author.setLastName(lastName); author.setSalutation(salutation); author.setEmail(email); author.setOfficeNo(officeNo); // author.setRemoteId(remoteId); // author.setIdType(idType); author.setCompanyId(user.getCompanyId()); author.setGroupId(groupId); author.setCreateDate(now); author.setModifiedDate(now); author.setUuid(PortalUUIDUtil.generate()); author.setCreatedBy(createdByUserId); //author.setPersonalSite(personalSite); logger.info("author creted:" + authorId); author.setItemCount(0); if (expertiseNames != null) { long siteGroupId = PortalUtil.getSiteGroupId(groupId); Group siteGroup = GroupLocalServiceUtil.getGroup(siteGroupId); List<Expertise> expertises = ExpertiseLocalServiceUtil.checkExpertises(userId, siteGroup, expertiseNames); for (Expertise expertise : expertises) { expertiseLocalService.incrementAuthorCount(expertise.getExpertiseId()); } setExpertises(authorId, expertises); } if (researchInterestNames != null) { long siteGroupId = PortalUtil.getSiteGroupId(groupId); Group siteGroup = GroupLocalServiceUtil.getGroup(siteGroupId); List<ResearchInterest> researchInterests = ResearchInterestLocalServiceUtil .checkResearchInterests(userId, siteGroup, researchInterestNames); for (ResearchInterest researchInterest : researchInterests) { researchInterestLocalService.incrementAuthorCount(researchInterest.getResearchInterestId()); } setResearchInterests(authorId, researchInterests); } updateAuthorSite(authorId, authorSite); //long coverPhotoId = attachCoverPhoto(author,serviceContext); //author.setCoverPhotoId(coverPhotoId); authorPersistence.update(author); AssetEntry assetEntry = updateAssetEntry(createdByUserId, groupId, author, serviceContext); resourceLocalService.addResources(author.getCompanyId(), author.getGroupId(), createdByUserId, Author.class.getName(), author.getAuthorId(), false, true, true); /* addResource(author.getCompanyId(),author.getGroupId(), createdByUserId,author.getAuthorId()); */ AssetLinkLocalServiceUtil.updateLinks(userId, assetEntry.getEntryId(), serviceContext.getAssetLinkEntryIds(), AssetLinkConstants.TYPE_RELATED); Indexer indexer = IndexerRegistryUtil.nullSafeGetIndexer(Author.class); indexer.reindex(author); return authorId; }
From source file:com.idetronic.subur.service.impl.AuthorLocalServiceImpl.java
License:Open Source License
/** * Update existing author, throw Exception if author not found or update fails * @param authorId/* w ww. j a v a2 s .c o m*/ * @param firstName * @param lastName * @param remoteId * @param idType * @param userId * @param groupId * @return * @throws SystemException * @throws PortalException */ public Author updateAuthor(long authorId, String salutation, String firstName, String middleName, String lastName, String email, String officeNo, Map<String, String> authorSite, String title, long userId, long groupId, long createdByUserId, String[] expertiseNames, String[] researchInterestNames, ServiceContext serviceContext) throws SystemException, PortalException, IOException { Author author = authorPersistence.fetchByPrimaryKey(authorId); author.setSalutation(salutation); author.setMiddleName(middleName); author.setFirstName(firstName); author.setLastName(lastName); author.setEmail(email); author.setOfficeNo(officeNo); author.setTitle(title); if (expertiseNames != null) { long siteGroupId = PortalUtil.getSiteGroupId(groupId); Group siteGroup = GroupLocalServiceUtil.getGroup(siteGroupId); //get existing author expertise and decrement the count List<Expertise> oldExpertises = getExpertises(authorId); List<Expertise> newExpertises = ExpertiseLocalServiceUtil.checkExpertises(userId, siteGroup, expertiseNames); for (Expertise expertise : oldExpertises) { if (!newExpertises.contains(expertise)) expertiseLocalService.decrementAuthorCount(expertise.getExpertiseId()); } for (Expertise expertise : newExpertises) { if (!oldExpertises.contains(expertise)) expertiseLocalService.incrementAuthorCount(expertise.getExpertiseId()); } setExpertises(authorId, newExpertises); } if (researchInterestNames != null) { long siteGroupId = PortalUtil.getSiteGroupId(groupId); Group siteGroup = GroupLocalServiceUtil.getGroup(siteGroupId); //get existing author expertise and decrement the count List<ResearchInterest> oldResearchInterests = getResearchInterests(authorId); List<ResearchInterest> newResearchInterests = ResearchInterestLocalServiceUtil .checkResearchInterests(userId, siteGroup, researchInterestNames); for (ResearchInterest researchInterest : oldResearchInterests) { if (!newResearchInterests.contains(researchInterest)) researchInterestLocalService.decrementAuthorCount(researchInterest.getResearchInterestId()); } for (ResearchInterest researchInterest : newResearchInterests) { if (!oldResearchInterests.contains(researchInterest)) researchInterestLocalService.incrementAuthorCount(researchInterest.getResearchInterestId()); } setResearchInterests(authorId, newResearchInterests); } //author Site updateAuthorSite(authorId, authorSite); authorPersistence.update(author); resourceLocalService.updateResources(serviceContext.getCompanyId(), serviceContext.getScopeGroupId(), author.getDisplayName(), author.getAuthorId(), serviceContext.getGroupPermissions(), serviceContext.getGuestPermissions()); AssetEntry assetEntry = updateAssetEntry(createdByUserId, groupId, author, serviceContext); AssetLinkLocalServiceUtil.updateLinks(userId, assetEntry.getEntryId(), serviceContext.getAssetLinkEntryIds(), AssetLinkConstants.TYPE_RELATED); Indexer indexer = IndexerRegistryUtil.nullSafeGetIndexer(Author.class); indexer.reindex(author); return author; }
From source file:com.idetronic.subur.service.impl.SuburItemLocalServiceImpl.java
License:Open Source License
@Override public SuburItem updateSuburItem(SuburItem suburItem, long userId, int newStatus, long[] itemTypeIds, long[] authorIds, ServiceContext serviceContext) throws PortalException, SystemException { long groupId = serviceContext.getScopeGroupId(); suburItem.setStatusDate(new Date()); if (Validator.isNull(suburItem.getPublishedDate()) && suburItem.getStatus() == SuburConstant.STATUS_PUBLISHED_ITEM) suburItem.setPublishedDate(new Date()); //only show item with published status boolean visible = false; String itemDescription = null; String summary = null;/*from www.ja v a2 s .c o m*/ String url = null; String layoutUuid = null; Date publishedDate = suburItem.getPublishedDate(); suburItem.getMetadataValue(); itemDescription = suburItem.getTitle(); AssetEntry assetEntry = assetEntryLocalService.updateEntry(userId, groupId, suburItem.getCreateDate(), suburItem.getModifiedDate(), SuburItem.class.getName(), suburItem.getItemId(), suburItem.getUuid(), 0, serviceContext.getAssetCategoryIds(), serviceContext.getAssetTagNames(), visible, null, null, null, ContentTypes.TEXT_HTML, suburItem.getTitle(), itemDescription, summary, url, layoutUuid, 0, 0, null, false); if (suburItem.isDraft() || suburItem.isPending()) { } else { suburItem.setStatus(WorkflowConstants.STATUS_DRAFT); } //if status is published, ensure to update asset entry published date if (Validator.isNull(assetEntry.getPublishDate()) && suburItem.getStatus() == WorkflowConstants.STATUS_APPROVED) assetEntryLocalService.updateEntry(SuburItem.class.getName(), suburItem.getItemId(), suburItem.getPublishedDate(), true); assetLinkLocalService.updateLinks(userId, assetEntry.getEntryId(), serviceContext.getAssetLinkEntryIds(), AssetLinkConstants.TYPE_RELATED); ItemAuthorLocalServiceUtil.setItemAuthor(suburItem.getItemId(), authorIds, suburItem.getStatus()); //AuthorLocalServiceUtil.updateAuthorPosting(suburItem); resourceLocalService.addResources(serviceContext.getCompanyId(), groupId, userId, SuburItem.class.getName(), suburItem.getItemId(), false, true, true); ItemItemTypeLocalServiceUtil.updateItemItemType(suburItem.getItemId(), itemTypeIds); //workflow boolean workFlowEnable = SuburUtil.isWorkflowEnabled(serviceContext); serviceContext.setAttribute("trackbacks", null); if (workFlowEnable) { WorkflowHandlerRegistryUtil.startWorkflowInstance(suburItem.getCompanyId(), suburItem.getGroupId(), userId, SuburItem.class.getName(), suburItem.getItemId(), suburItem, serviceContext); } Indexer indexer = IndexerRegistryUtil.nullSafeGetIndexer(SuburItem.class); if (serviceContext.getWorkflowAction() == WorkflowConstants.ACTION_PUBLISH) { suburItem.setStatus(WorkflowConstants.STATUS_PENDING); JSONObject extraDataJSONObject = JSONFactoryUtil.createJSONObject(); extraDataJSONObject.put("title", suburItem.getTitle()); if (suburItem.getCompleted()) { SocialActivityLocalServiceUtil.addActivity(userId, suburItem.getGroupId(), SuburItem.class.getName(), suburItem.getItemId(), SuburActivityKeys.UPDATE_SUBUR_PUBLICATION, extraDataJSONObject.toString(), 0); } else { SocialActivityLocalServiceUtil.addActivity(userId, suburItem.getGroupId(), SuburItem.class.getName(), suburItem.getItemId(), SuburActivityKeys.ADD_SUBUR_PUBLICATION, extraDataJSONObject.toString(), 0); suburItem.setCompleted(true); } } indexer.reindex(suburItem); suburItem.setExpandoBridgeAttributes(serviceContext); //updateStatus(suburItem.getItemId(),userId,newStatus,serviceContext); return suburItemPersistence.update(suburItem); }
From source file:com.idetronic.subur.service.impl.SuburItemLocalServiceImpl.java
License:Open Source License
public void deleteItem(SuburItem suburItem) throws SystemException, PortalException { resourceLocalService.deleteResource(suburItem.getCompanyId(), SuburItem.class.getName(), ResourceConstants.SCOPE_INDIVIDUAL, suburItem.getItemId()); List<ItemItemType> itemTypes = ItemItemTypeLocalServiceUtil.getByItemId(suburItem.getItemId()); for (ItemItemType iType : itemTypes) { itemItemTypePersistence.remove(iType); ItemTypeLocalServiceUtil.decrementCounter(iType.getItemTypeId()); }/*from w w w . j a v a2 s. c o m*/ AuthorLocalServiceUtil.deleteItem(suburItem.getItemId()); // Asset assetEntryLocalService.deleteEntry(SuburItem.class.getName(), suburItem.getItemId()); suburItemPersistence.remove(suburItem); // Indexer Indexer indexer = IndexerRegistryUtil.nullSafeGetIndexer(SuburItem.class); indexer.delete(suburItem); }
From source file:com.idetronic.subur.service.impl.SuburItemLocalServiceImpl.java
License:Open Source License
/** * Withdraw item from public viewing/*w ww . j a v a 2 s .com*/ * @param itemId * @return * @throws SystemException * @throws PortalException */ public SuburItem withDrawItem(long itemId) throws SystemException, PortalException { SuburItem suburItem = suburItemPersistence.fetchByPrimaryKey(itemId); suburItem.setStatus(SuburConstant.STATUS_WITHDRAWN_ITEM); assetEntryLocalService.updateEntry(SuburItem.class.getName(), suburItem.getItemId(), null, false); Indexer indexer = IndexerRegistryUtil.nullSafeGetIndexer(SuburItem.class); indexer.reindex(suburItem); return suburItemPersistence.update(suburItem); }