ProductManagerBean implements IProductManagerLocal { @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @Override public PartRevision updatePartIteration(PartIterationKey pKey, String pIterationNote, Source source, List<PartUsageLink> pUsageLinks, List<InstanceAttribute> pAttributes, List<InstanceAttributeTemplate> pAttributeTemplates, DocumentRevisionKey[] pLinkKeys, String[] documentLinkComments, String[] lovNames) throws UserNotFoundException, WorkspaceNotFoundException, AccessRightException, NotAllowedException, PartRevisionNotFoundException, PartMasterNotFoundException, EntityConstraintException, UserNotActiveException, ListOfValuesNotFoundException, PartUsageLinkNotFoundException, DocumentRevisionNotFoundException, WorkspaceNotEnabledException { User user = userManager.checkWorkspaceReadAccess(pKey.getWorkspaceId()); PartRevision partRev = partRevisionDAO.loadPartR(pKey.getPartRevision()); if (partRev.getACL() == null) { userManager.checkWorkspaceWriteAccess(pKey.getWorkspaceId()); } if (!hasPartRevisionWriteAccess(user, partRev)) { throw new AccessRightException(user); } PartIteration partIte = partRev.getLastIteration(); if (isCheckoutByUser(user, partRev) && partIte.getKey().equals(pKey)) { if (pLinkKeys != null) { Set<DocumentLink> currentLinks = new HashSet<>(partIte.getLinkedDocuments()); for (DocumentLink link : currentLinks) { partIte.getLinkedDocuments().remove(link); } int counter = 0; for (DocumentRevisionKey link : pLinkKeys) { DocumentLink newLink = new DocumentLink(documentRevisionDAO.loadDocR(link)); newLink.setComment(documentLinkComments[counter]); documentLinkDAO.createLink(newLink); partIte.getLinkedDocuments().add(newLink); counter++; } } if (pAttributes != null) { List<InstanceAttribute> currentAttrs = partRev.getLastIteration().getInstanceAttributes(); boolean valid = AttributesConsistencyUtils.hasValidChange(pAttributes, partRev.isAttributesLocked(), currentAttrs); if (!valid) { throw new NotAllowedException("NotAllowedException59"); } partRev.getLastIteration().setInstanceAttributes(pAttributes); } if (pAttributeTemplates != null) { List<InstanceAttributeTemplate> templateAttrs = new ArrayList<>(); for (int i = 0; i < pAttributeTemplates.size(); i++) { templateAttrs.add(pAttributeTemplates.get(i)); if (pAttributeTemplates.get(i) instanceof ListOfValuesAttributeTemplate) { ListOfValuesAttributeTemplate lovAttr = (ListOfValuesAttributeTemplate) pAttributeTemplates.get(i); ListOfValuesKey lovKey = new ListOfValuesKey(user.getWorkspaceId(), lovNames[i]); lovAttr.setLov(lovDAO.loadLOV(lovKey)); } } if (!AttributesConsistencyUtils.isTemplateAttributesValid(templateAttrs, false)) { throw new NotAllowedException("NotAllowedException59"); } partIte.setInstanceAttributeTemplates(pAttributeTemplates); } if (pUsageLinks != null) { List<PartUsageLink> links = new ArrayList<>(); for (PartUsageLink usageLink : pUsageLinks) { PartUsageLink partUsageLink = findOrCreatePartLink(usageLink); links.add(partUsageLink); } partIte.setComponents(links); partUsageLinkDAO.removeOrphanPartLinks(); removeObsoletePathToPathLinks(pKey.getWorkspaceId()); checkCyclicAssemblyForPartIteration(partIte); } partIte.setIterationNote(pIterationNote); partIte.setModificationDate(new Date()); partIte.setSource(source); } else { throw new NotAllowedException("NotAllowedException25", partIte.getPartNumber()); } return partRev; }  @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @Override List<PartLink[]> findPartUsages(ConfigurationItemKey pKey, ProductStructureFilter filter, String search); @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @Override List<PartMaster> findPartMasters(String pWorkspaceId, String pPartNumber, String pPartName, int pMaxResults); @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @Override ConfigurationItem createConfigurationItem(String pWorkspaceId, String pId, String pDescription, String pDesignItemNumber); @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @Override PartMaster createPartMaster(String pWorkspaceId, String pNumber, String pName, boolean pStandardPart, String pWorkflowModelId, String pPartRevisionDescription, String templateId, Map<String, String> pACLUserEntries, Map<String, String> pACLUserGroupEntries, Map<String, Collection<String>> userRoleMapping, Map<String, Collection<String>> groupRoleMapping); @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @Override PartRevision undoCheckOutPart(PartRevisionKey pPartRPK); @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @Override PartRevision checkOutPart(PartRevisionKey pPartRPK); @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @Override PartRevision checkInPart(PartRevisionKey pPartRPK); @RolesAllowed({UserGroupMapping.REGULAR_USER_ROLE_ID}) @Override BinaryResource getBinaryResource(String pFullName); @RolesAllowed({UserGroupMapping.REGULAR_USER_ROLE_ID}) @Override BinaryResource getTemplateBinaryResource(String pFullName); @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @Override BinaryResource saveNativeCADInPartIteration(PartIterationKey pPartIPK, String pName, long pSize); @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @Override BinaryResource saveGeometryInPartIteration(PartIterationKey pPartIPK, String pName, int quality, long pSize, double[] box); @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @Override BinaryResource saveFileInPartIteration(PartIterationKey pPartIPK, String pName, String subType, long pSize); @RolesAllowed({UserGroupMapping.REGULAR_USER_ROLE_ID, UserGroupMapping.ADMIN_ROLE_ID}) @Override List<ConfigurationItem> getConfigurationItems(String pWorkspaceId); @RolesAllowed({UserGroupMapping.REGULAR_USER_ROLE_ID, UserGroupMapping.ADMIN_ROLE_ID}) @Override List<ConfigurationItem> searchConfigurationItems(String pWorkspaceId, String q); @RolesAllowed({UserGroupMapping.REGULAR_USER_ROLE_ID, UserGroupMapping.ADMIN_ROLE_ID}) @Override ConfigurationItem getConfigurationItem(ConfigurationItemKey ciKey); @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @Override PartRevision updatePartIteration(PartIterationKey pKey, String pIterationNote, Source source, List<PartUsageLink> pUsageLinks, List<InstanceAttribute> pAttributes, List<InstanceAttributeTemplate> pAttributeTemplates, DocumentRevisionKey[] pLinkKeys, String[] documentLinkComments, String[] lovNames); @RolesAllowed({UserGroupMapping.REGULAR_USER_ROLE_ID}) @Override PartRevision getPartRevision(PartRevisionKey pPartRPK); @RolesAllowed({UserGroupMapping.REGULAR_USER_ROLE_ID}) @Override List<ModificationNotification> getModificationNotifications(PartIterationKey pPartIPK); @RolesAllowed({UserGroupMapping.REGULAR_USER_ROLE_ID}) @Override void removeModificationNotificationsOnIteration(PartIterationKey pPartIPK); @RolesAllowed({UserGroupMapping.REGULAR_USER_ROLE_ID}) @Override void removeModificationNotificationsOnRevision(PartRevisionKey pPartRPK); @RolesAllowed({UserGroupMapping.REGULAR_USER_ROLE_ID}) @Override void createModificationNotifications(PartIteration modifiedPartIteration); @RolesAllowed({UserGroupMapping.REGULAR_USER_ROLE_ID}) @Override void updateModificationNotification(String pWorkspaceId, int pModificationNotificationId, String pAcknowledgementComment); @RolesAllowed({UserGroupMapping.REGULAR_USER_ROLE_ID}) @Override List<PartIteration> getUsedByAsComponent(PartRevisionKey partRevisionKey); @RolesAllowed({UserGroupMapping.REGULAR_USER_ROLE_ID}) @Override List<PartIteration> getUsedByAsSubstitute(PartRevisionKey partRevisionKey); @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @Override PartIteration getPartIteration(PartIterationKey pPartIPK); @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @Override void updatePartRevisionACL(String workspaceId, PartRevisionKey revisionKey, Map<String, String> pACLUserEntries, Map<String, String> pACLUserGroupEntries); @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @Override void removeACLFromPartRevision(PartRevisionKey revisionKey); @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @Override List<PartRevision> searchPartRevisions(PartSearchQuery pQuery, int from, int size); @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @Override PartMaster findPartMasterByCADFileName(String workspaceId, String cadFileName); @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @Override Conversion getConversion(PartIterationKey partIterationKey); @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @TransactionAttribute(value = TransactionAttributeType.REQUIRES_NEW) @Override Conversion createConversion(PartIterationKey partIterationKey); @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @TransactionAttribute(value = TransactionAttributeType.REQUIRES_NEW) @Override void removeConversion(PartIterationKey partIterationKey); @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @TransactionAttribute(value = TransactionAttributeType.REQUIRES_NEW) @Override void endConversion(PartIterationKey partIterationKey, boolean succeed); @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @TransactionAttribute(value = TransactionAttributeType.REQUIRES_NEW) @Override Import createImport(String workspaceId, String fileName); @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @Override List<Import> getImports(String workspaceId, String filename); @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @Override Import getImport(String workspaceId, String id); @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @TransactionAttribute(value = TransactionAttributeType.REQUIRES_NEW) @Override void endImport(String workspaceId, String id, ImportResult importResult); @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @Override void removeImport(String workspaceId, String id); @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @Override void updateACLForPartMasterTemplate(String pWorkspaceId, String templateId, Map<String, String> userEntries, Map<String, String> groupEntries); @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @Override void removeACLFromPartMasterTemplate(String workspaceId, String partTemplateId); @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @Override PartRevision saveTags(PartRevisionKey revisionKey, String[] pTags); @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @Override PartRevision removeTag(PartRevisionKey partRevisionKey, String tagName); @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @Override PartRevision[] findPartRevisionsByTag(String workspaceId, String tagId); @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @Override PartRevision[] getPartRevisionsWithReferenceOrName(String pWorkspaceId, String reference, int maxResults); @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @Override PartRevision releasePartRevision(PartRevisionKey pRevisionKey); @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @Override PartRevision markPartRevisionAsObsolete(PartRevisionKey pRevisionKey); @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @Override PartRevision getLastReleasePartRevision(ConfigurationItemKey ciKey); @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @Override List<ProductBaseline> findBaselinesWherePartRevisionHasIterations(PartRevisionKey partRevisionKey); @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @Override List<PartUsageLink> getComponents(PartIterationKey pPartIPK); @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @Override boolean partMasterExists(PartMasterKey partMasterKey); @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @Override void deleteConfigurationItem(ConfigurationItemKey configurationItemKey); @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @Override void deleteLayer(String workspaceId, int layerId); @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @Override BinaryResource renameFileInPartIteration(String pSubType, String pFullName, String pNewName); @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @Override void removeFileInPartIteration(PartIterationKey pPartIPK, String pSubType, String pName); @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @Override void setPublicSharedPart(PartRevisionKey pPartRPK, boolean isPublicShared); @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @Override PartMaster getPartMaster(PartMasterKey pPartMPK); @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @Override List<Layer> getLayers(ConfigurationItemKey pKey); @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @Override Layer getLayer(int pId); @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @Override Layer createLayer(ConfigurationItemKey pKey, String pName, String color); @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @Override Layer updateLayer(ConfigurationItemKey pKey, int pId, String pName, String color); @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @Override Marker createMarker(int pLayerId, String pTitle, String pDescription, double pX, double pY, double pZ); @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @Override void deleteMarker(int pLayerId, int pMarkerId); @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @Override PartMasterTemplate[] getPartMasterTemplates(String pWorkspaceId); @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @Override PartMasterTemplate getPartMasterTemplate(PartMasterTemplateKey pKey); @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @Override PartMasterTemplate createPartMasterTemplate(String pWorkspaceId, String pId, String pPartType, String pWorkflowModelId, String pMask, List<InstanceAttributeTemplate> pAttributeTemplates, String[] lovNames, List<InstanceAttributeTemplate> pAttributeInstanceTemplates, String[] instanceLovNames, boolean idGenerated, boolean attributesLocked); @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @Override PartMasterTemplate updatePartMasterTemplate(PartMasterTemplateKey pKey, String pPartType, String pWorkflowModelId, String pMask, List<InstanceAttributeTemplate> pAttributeTemplates, String[] lovNames, List<InstanceAttributeTemplate> pAttributeInstanceTemplates, String[] instanceLovNames, boolean idGenerated, boolean attributesLocked); @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @Override void deletePartMasterTemplate(PartMasterTemplateKey pKey); @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @Override BinaryResource saveFileInTemplate(PartMasterTemplateKey pPartMTemplateKey, String pName, long pSize); @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @Override PartMasterTemplate removeFileFromTemplate(String pFullName); @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @Override BinaryResource renameFileInTemplate(String pFullName, String pNewName); @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @Override List<PartMaster> getPartMasters(String pWorkspaceId, int start, int pMaxResults); @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @Override List<PartRevision> getPartRevisions(String pWorkspaceId, int start, int pMaxResults); @RolesAllowed({UserGroupMapping.REGULAR_USER_ROLE_ID, UserGroupMapping.ADMIN_ROLE_ID}) @Override int getPartsInWorkspaceCount(String pWorkspaceId); @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @Override void deletePartRevision(PartRevisionKey partRevisionKey); @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @Override int getNumberOfIteration(PartRevisionKey partRevisionKey); @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @Override PartRevision createPartRevision(PartRevisionKey revisionKey, String pDescription, String pWorkflowModelId, Map<String, String> pACLUserEntries, Map<String, String> pACLUserGroupEntries, Map<String, Collection<String>> userRoleMapping, Map<String, Collection<String>> groupRoleMapping); @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @Override String generateId(String pWorkspaceId, String pPartMTemplateId); @RolesAllowed({UserGroupMapping.REGULAR_USER_ROLE_ID, UserGroupMapping.ADMIN_ROLE_ID}) @Override long getDiskUsageForPartsInWorkspace(String pWorkspaceId); @RolesAllowed({UserGroupMapping.REGULAR_USER_ROLE_ID, UserGroupMapping.ADMIN_ROLE_ID}) @Override long getDiskUsageForPartTemplatesInWorkspace(String pWorkspaceId); @Override PartRevision[] getCheckedOutPartRevisions(String pWorkspaceId); @RolesAllowed({UserGroupMapping.REGULAR_USER_ROLE_ID, UserGroupMapping.ADMIN_ROLE_ID}) @Override PartRevision[] getAllCheckedOutPartRevisions(String pWorkspaceId); @RolesAllowed({UserGroupMapping.REGULAR_USER_ROLE_ID}) @Override SharedPart createSharedPart(PartRevisionKey pPartRevisionKey, String pPassword, Date pExpireDate); @RolesAllowed({UserGroupMapping.REGULAR_USER_ROLE_ID}) @Override void deleteSharedPart(SharedEntityKey pSharedEntityKey); @RolesAllowed({UserGroupMapping.REGULAR_USER_ROLE_ID, UserGroupMapping.ADMIN_ROLE_ID}) @Override boolean canAccess(PartRevisionKey partRKey); @RolesAllowed({UserGroupMapping.REGULAR_USER_ROLE_ID, UserGroupMapping.ADMIN_ROLE_ID}) @Override boolean canAccess(PartIterationKey partIKey); @RolesAllowed({UserGroupMapping.REGULAR_USER_ROLE_ID, UserGroupMapping.ADMIN_ROLE_ID}) @Override boolean canUserAccess(User user, PartRevisionKey partRKey); @RolesAllowed({UserGroupMapping.REGULAR_USER_ROLE_ID, UserGroupMapping.ADMIN_ROLE_ID}) @Override boolean canUserAccess(User user, PartIterationKey partIKey); @RolesAllowed({UserGroupMapping.REGULAR_USER_ROLE_ID, UserGroupMapping.ADMIN_ROLE_ID}) @Override User checkPartRevisionReadAccess(PartRevisionKey partRevisionKey); @RolesAllowed({UserGroupMapping.REGULAR_USER_ROLE_ID, UserGroupMapping.ADMIN_ROLE_ID}) @Override boolean canWrite(PartRevisionKey partRKey); @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @Override Component filterProductStructure(ConfigurationItemKey ciKey, ProductStructureFilter filter, List<PartLink> path, Integer pDepth); @Override @RolesAllowed({UserGroupMapping.REGULAR_USER_ROLE_ID, UserGroupMapping.ADMIN_ROLE_ID}) Set<PartRevision> getWritablePartRevisionsFromPath(ConfigurationItemKey configurationItemKey, String path); @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @Override Component filterProductStructureOnLinkType(ConfigurationItemKey ciKey, ProductStructureFilter filter, String configSpecType, String path, String linkType); @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @Override List<PartLink> decodePath(ConfigurationItemKey ciKey, String path); @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @Override List<PartRevision> searchPartRevisions(String workspaceId, Query query); @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @Override Query getQuery(String workspaceId, int queryId); @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @Override void createQuery(String workspaceId, Query query); @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @Override void deleteQuery(String workspaceId, int queryId); @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @Override List<Query> getQueries(String workspaceId); @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @Override PartLink getRootPartUsageLink(ConfigurationItemKey pKey); @RolesAllowed({UserGroupMapping.REGULAR_USER_ROLE_ID, UserGroupMapping.ADMIN_ROLE_ID}) @Override void checkCyclicAssemblyForPartIteration(PartIteration partIteration); @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @Override ProductStructureFilter getLatestCheckedInPSFilter(String workspaceId); @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @Override boolean hasModificationNotification(ConfigurationItemKey ciKey); @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @Override List<InstanceAttribute> getPartIterationsInstanceAttributesInWorkspace(String workspaceId); @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @Override List<InstanceAttribute> getPathDataInstanceAttributesInWorkspace(String workspaceId); @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @Override List<QueryResultRow> filterProductBreakdownStructure(String workspaceId, Query query); @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @Override List<BinaryResource> getBinaryResourceFromBaseline(int baselineId); @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @Override Map<String, Set<BinaryResource>> getBinariesInTree(Integer baselineId, String workspaceId, ConfigurationItemKey ciKey, ProductStructureFilter psFilter, boolean exportNativeCADFiles, boolean exportDocumentLinks); @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @Override ProductBaseline loadProductBaselineForProductInstanceMaster(ConfigurationItemKey ciKey, String serialNumber); @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @Override Query loadQuery(String workspaceId, int queryId); @RolesAllowed({UserGroupMapping.REGULAR_USER_ROLE_ID}) @Override List<PartIteration> getInversePartsLink(DocumentRevisionKey docKey); @RolesAllowed({UserGroupMapping.REGULAR_USER_ROLE_ID}) @Override Set<ProductInstanceMaster> getInverseProductInstancesLink(DocumentRevisionKey docKey); @RolesAllowed({UserGroupMapping.REGULAR_USER_ROLE_ID}) @Override Set<PathDataMaster> getInversePathDataLink(DocumentRevisionKey docKey); @RolesAllowed({UserGroupMapping.REGULAR_USER_ROLE_ID}) @Override PathToPathLink createPathToPathLink(String workspaceId, String configurationItemId, String type, String pathFrom, String pathTo, String description); @RolesAllowed({UserGroupMapping.REGULAR_USER_ROLE_ID}) @Override PathToPathLink updatePathToPathLink(String workspaceId, String configurationItemId, int pathToPathLinkId, String description); @RolesAllowed({UserGroupMapping.REGULAR_USER_ROLE_ID}) @Override List<String> getPathToPathLinkTypes(String workspaceId, String configurationItemId); @RolesAllowed({UserGroupMapping.REGULAR_USER_ROLE_ID}) @Override List<PathToPathLink> getPathToPathLinkFromSourceAndTarget(String workspaceId, String configurationItemId, String sourcePath, String targetPath); @RolesAllowed({UserGroupMapping.REGULAR_USER_ROLE_ID}) @Override ProductInstanceMaster findProductByPathMaster(String workspaceId, PathDataMaster pathDataMaster); @RolesAllowed({UserGroupMapping.REGULAR_USER_ROLE_ID}) @Override PartMaster getPartMasterFromPath(String workspaceId, String configurationItemId, String partPath); @RolesAllowed({UserGroupMapping.REGULAR_USER_ROLE_ID}) @Override void deletePathToPathLink(String workspaceId, String configurationItemId, int pathToPathLinkId); @RolesAllowed({UserGroupMapping.REGULAR_USER_ROLE_ID}) @Override List<ResolvedDocumentLink> getDocumentLinksAsDocumentIterations(String workspaceId, String configurationItemId, String configSpec, PartIterationKey partIterationKey); @RolesAllowed({UserGroupMapping.REGULAR_USER_ROLE_ID}) @Override PartIteration findPartIterationByBinaryResource(BinaryResource binaryResource); @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @Override PartRevision[] getPartRevisionsWithAssignedTasksForGivenUser(String pWorkspaceId, String assignedUserLogin); @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @Override PartRevision[] getPartRevisionsWithOpenedTasksForGivenUser(String pWorkspaceId, String assignedUserLogin);  }
@Test public void updatePartWithLockedAttributes() throws Exception { InstanceAttribute attribute = new InstanceTextAttribute("Test", "Testeur", false); List<InstanceAttribute> attributesOfIteration = new ArrayList<>(); attributesOfIteration.add(attribute); partIteration.setInstanceAttributes(attributesOfIteration); partMaster.setAttributesLocked(true); Mockito.when(userManager.checkWorkspaceReadAccess(workspace.getId())).thenReturn(user); Mockito.when(userManager.checkWorkspaceWriteAccess(workspace.getId())).thenReturn(user); Mockito.when(partRevisionDAO.loadPartR(partRevision.getKey())).thenReturn(partRevision); ArrayList<PartUsageLink> partUsageLinks = new ArrayList<>(); ArrayList<InstanceAttribute> newAttributes = new ArrayList<>(); ArrayList<InstanceAttributeTemplate> newAttributeTemplates = new ArrayList<>(); String[] lovNames = new String[0]; try { productManagerBean.updatePartIteration(partIteration.getKey(), "Iteration note", null, partUsageLinks, newAttributes, newAttributeTemplates, new DocumentRevisionKey[]{}, null, lovNames); Assert.fail("updatePartIteration should have raise an exception because we have removed attributes"); } catch (NotAllowedException notAllowedException) { try { newAttributes.add(new InstanceDateAttribute("Test", new Date(), false)); productManagerBean.updatePartIteration(partIteration.getKey(), "Iteration note", null, partUsageLinks, newAttributes, newAttributeTemplates, new DocumentRevisionKey[]{}, null, lovNames); Assert.fail("updateDocument should have raise an exception because we have changed the attribute type attributes"); } catch (NotAllowedException notAllowedException2) { try { newAttributes = new ArrayList<>(); newAttributes.add(attribute); productManagerBean.updatePartIteration(partIteration.getKey(), "Iteration note", null, partUsageLinks, newAttributes, newAttributeTemplates, new DocumentRevisionKey[]{}, null, lovNames); newAttributes = new ArrayList<>(); newAttributes.add(new InstanceTextAttribute("Test", "newValue", false)); productManagerBean.updatePartIteration(partIteration.getKey(), "Iteration note", null, partUsageLinks, newAttributes, newAttributeTemplates, new DocumentRevisionKey[]{}, null, lovNames); } catch (NotAllowedException notAllowedException3) { Assert.fail("updateDocument shouldn't have raised an exception because we haven't change the number of attribute or the type"); } } } Mockito.verify(indexerManager, Mockito.never()).indexPartIteration(Mockito.any(PartIteration.class)); }
@Test public void updatePartWithUnlockedAttributes() throws Exception { InstanceAttribute attribute = new InstanceTextAttribute("Test", "Testeur", false); List<InstanceAttribute> attributesOfIteration = new ArrayList<>(); attributesOfIteration.add(attribute); partIteration.setInstanceAttributes(attributesOfIteration); partMaster.setAttributesLocked(false); Mockito.when(userManager.checkWorkspaceReadAccess(workspace.getId())).thenReturn(user); Mockito.when(userManager.checkWorkspaceWriteAccess(workspace.getId())).thenReturn(user); Mockito.when(partRevisionDAO.loadPartR(partRevision.getKey())).thenReturn((partRevision)); ArrayList<PartUsageLink> partUsageLinks = new ArrayList<>(); ArrayList<InstanceAttribute> newAttributes = new ArrayList<>(); ArrayList<InstanceAttributeTemplate> newAttributeTemplates = new ArrayList<>(); String[] lovNames = new String[0]; try { productManagerBean.updatePartIteration(partIteration.getKey(), "Iteration note", null, partUsageLinks, newAttributes, newAttributeTemplates, new DocumentRevisionKey[]{}, null, lovNames); newAttributes.add(new InstanceDateAttribute("Test", new Date(), false)); productManagerBean.updatePartIteration(partIteration.getKey(), "Iteration note", null, partUsageLinks, newAttributes, newAttributeTemplates, new DocumentRevisionKey[]{}, null, lovNames); newAttributes = new ArrayList<>(); newAttributes.add(attribute); productManagerBean.updatePartIteration(partIteration.getKey(), "Iteration note", null, partUsageLinks, newAttributes, newAttributeTemplates, new DocumentRevisionKey[]{}, null, lovNames); newAttributes = new ArrayList<>(); newAttributes.add(new InstanceTextAttribute("Test", "newValue", false)); productManagerBean.updatePartIteration(partIteration.getKey(), "Iteration note", null, partUsageLinks, newAttributes, newAttributeTemplates, new DocumentRevisionKey[]{}, null, lovNames); } catch (NotAllowedException notAllowedException) { Assert.fail("updateDocument shouldn't have raised an exception because the attributes are not frozen"); } Mockito.verify(indexerManager, Mockito.never()).indexPartIteration(Mockito.any(PartIteration.class)); }