if(CSNUtil.isDraftEnabledEntity(entity.getName(), schema)|| CSNUtil.isDraftNodeEntity(entity.getName(), schema)) { Column col = formNewColumnObject(entity, DraftUtilsV4.DRAFTS_FOREIGN_KEY, dbalias, false, parentComplexName, eInfo);
if(CSNUtil.isDraftEnabledEntity(entitySet.getEntityType().getName(), serviceName)) { draftProvider.deleteEntry(uriInfo, context, DraftUtilsV2.DRAFTS_ADMIN_TABLE_NAME, draftAdminDataKeyMap, dataProvider.getDSParams());
private void correctionInMainEntities(Entity rootEntityExpanded,String serviceName,Map<String,List<String>> draftTree){ if(CSNUtil.isDraftEnabledEntity(rootEntityExpanded.getType().substring(serviceName.length()+1),serviceName)|| CSNUtil.isDraftNodeEntity(rootEntityExpanded.getType().substring(serviceName.length()+1),serviceName)) { addPropertiesToMainDraftEntity(rootEntityExpanded); if(rootEntityExpanded.getNavigationLinks()!=null && !rootEntityExpanded.getNavigationLinks().isEmpty()) { for(Link link:rootEntityExpanded.getNavigationLinks()) { if(link.getInlineEntity()!=null && draftTree.get(rootEntityExpanded.getType().substring(serviceName.length()+1)).contains(link.getInlineEntity().getType().substring(serviceName.length()+1))) { correctionInMainEntities(link.getInlineEntity(),serviceName,draftTree); continue; }else if(link.getInlineEntitySet()!=null&&link.getInlineEntitySet().getEntities()!=null&&!link.getInlineEntitySet().getEntities().isEmpty()) { for(Entity inLineEntityFromSet:link.getInlineEntitySet().getEntities()){ correctionInMainEntities(inLineEntityFromSet,serviceName,draftTree); } } } } } }
@Override public IDataProviderResponse readEntity(GetEntityUriInfo uriInfo, ODataContext context) throws ODataException { String entitySetName = uriInfo.getTargetEntitySet().getName(); try{ checkAuthorization(uriInfo,READ); } catch(UnauthorizedException ue){ logger.error("Read operation on this entity not allowed for this user"); return handleAuthorizationException(ue); } List<PathSegment> precedingSegments = context.getPathInfo().getPrecedingSegments(); String serviceName = precedingSegments.get(precedingSegments.size() - 1).getPath(); if(CSNUtil.isDraftEnabledEntity(entitySetName,serviceName)|| CSNUtil.isDraftNodeEntity(entitySetName, serviceName)) { return this.readEntityDraftFlow(uriInfo, context); }else{ return this.readEntityNonDraftFlow(uriInfo, context); } }
@Override public IDataProviderResponse updateEntity(PutMergePatchUriInfo uriInfo, ODataEntry content, String requestContentType, boolean merge, ODataContext context) throws ODataException { String entitySetName = uriInfo.getStartEntitySet().getName(); try{ GetEntityUriInfo uInfo = (GetEntityUriInfo) uriInfo; checkAuthorization(uInfo,WRITE); } catch(UnauthorizedException ue){ logger.error("Update operation on this entity not allowed for this user"); return handleAuthorizationException(ue); } List<PathSegment> precedingSegments = context.getPathInfo().getPrecedingSegments(); String serviceName = precedingSegments.get(precedingSegments.size() - 1).getPath(); if(CSNUtil.isDraftEnabledEntity(entitySetName,serviceName)|| CSNUtil.isDraftNodeEntity(entitySetName, serviceName)) { return autoSaveMergeEntityForDraft(uriInfo, content, requestContentType, merge, context); }else{ return updateEntityNonDraftFlow(uriInfo, content, requestContentType, merge, context); } }
@Override public IDataProviderResponse createEntity(PostUriInfo uriInfo, ODataEntry content, String requestContentType, ODataEntityProviderPropertiesBuilder providerPropertiesBuilder, ODataContext context) throws ODataException { String entitySetName = uriInfo.getTargetEntitySet().getName(); try{ GetEntityUriInfo uInfo = (GetEntityUriInfo) uriInfo; checkAuthorization(uInfo,WRITE); } catch(UnauthorizedException ue){ logger.error("Create operation on this entity not allowed for this user"); return handleAuthorizationException(ue); } List<PathSegment> precedingSegments = context.getPathInfo().getPrecedingSegments(); String serviceName = precedingSegments.get(precedingSegments.size() - 1).getPath(); if(CSNUtil.isDraftEnabledEntity(entitySetName,serviceName)|| CSNUtil.isDraftNodeEntity(entitySetName, serviceName)) { return createNewInDraftFlow(uriInfo, content, context); }else{ return createEntityNonDraftFlow(uriInfo, content, requestContentType, providerPropertiesBuilder, context); } }
@Override public IDataProviderResponse readEntitySet(GetEntitySetUriInfo uriInfo, ODataContext context) throws ODataException { String entitySetName = uriInfo.getTargetEntitySet().getName(); try{ GetEntityUriInfo uInfo = (GetEntityUriInfo) uriInfo; checkAuthorization(uInfo,READ); } catch(UnauthorizedException ue){ logger.error("Read operation on this entity set not allowed for this user"); return handleAuthorizationException(ue); } List<PathSegment> precedingSegments = context.getPathInfo().getPrecedingSegments(); String serviceName = precedingSegments.get(precedingSegments.size() - 1).getPath(); if(CSNUtil.isDraftEnabledEntity(entitySetName,serviceName)|| CSNUtil.isDraftNodeEntity(entitySetName, serviceName)) { return this.readEntitySetDraftFlow(uriInfo, context); }else{ return this.readEntitySetNonDraftFlow(uriInfo, context); } }
@Override public IDataProviderResponse deleteEntity(DeleteUriInfo uriInfo, ODataContext context) throws ODataException { LocaleUtil.setLocaleForRequest(context); String entitySetName = uriInfo.getStartEntitySet().getName(); try{ GetEntityUriInfo uInfo = (GetEntityUriInfo) uriInfo; checkAuthorization(uInfo,WRITE); } catch(UnauthorizedException ue){ logger.error("Delete operation not allowed for this user"); return handleAuthorizationException(ue); } List<PathSegment> precedingSegments = context.getPathInfo().getPrecedingSegments(); String serviceName = precedingSegments.get(precedingSegments.size() - 1).getPath(); if(CSNUtil.isDraftEnabledEntity(entitySetName,serviceName)|| CSNUtil.isDraftNodeEntity(entitySetName, serviceName)) { return deleteDraftEntries((UriInfo)uriInfo, context); }else{ return deleteCascadeOnEntity(uriInfo, context, false); } }