List of usage examples for org.apache.commons.lang NullArgumentException NullArgumentException
public NullArgumentException(String argName)
Instantiates with the given argument name.
From source file:org.nuclos.server.genericobject.ejb3.GenericObjectFacadeHelper.java
/** * @param attrcvo/*from w w w . j a va 2 s. c o m*/ * @param oValue * @param bLogbookTracking * @throws CreateException * @throws CommonValidationException * @precondition attrcvo != null * @precondition oValue != null */ private void storeAttributeValue(GenericObjectVO govo, AttributeCVO attrcvo, Object oValue, boolean bLogbookTracking) throws CommonValidationException, NuclosBusinessException { if (oValue == null) { throw new NullArgumentException("oValue"); } final DynamicAttributeVO attrvo = new DynamicAttributeVO(attrcvo.getId(), null, oValue); }
From source file:org.nuclos.server.masterdata.ejb3.MasterDataFacadeBean.java
private void createOrModifyDependants(String entityName, Integer id, Boolean removed, DependantMasterDataMap dependants, boolean read, boolean remove, String customUsage) throws CommonCreateException, CommonFinderException, CommonRemoveException, CommonPermissionException, CommonStaleVersionException {// w w w .ja va 2 s . c om // todo: check and clean thrown exception types to necessary minimum if (dependants == null) { throw new NullArgumentException("dependants"); } LayoutFacadeLocal layoutFacade = ServerServiceLocator.getInstance().getFacade(LayoutFacadeLocal.class); Map<EntityAndFieldName, String> mpEntityAndParentEntityName = layoutFacade .getSubFormEntityAndParentSubFormEntityNames(entityName, id, false, customUsage); if (read) { readAllDependants(entityName, id, dependants, removed, null, mpEntityAndParentEntityName); } if (remove) { helper.removeDependants(dependants, customUsage); } try { helper.createOrModifyDependants(dependants, entityName, this.getCurrentUserName(), this.getServerValidatesMasterDataValues(), null, mpEntityAndParentEntityName, customUsage); } catch (CommonValidationException ex) { // @todo check this exception handling throw new CommonCreateException(ex.getMessage(), ex); } }
From source file:org.nuclos.server.masterdata.ejb3.MasterDataFacadeBean.java
public MasterDataWithDependantsVO getWithDependants(String sEntityName, Integer iId, String customUsage) throws CommonFinderException, NuclosBusinessException, CommonPermissionException { if (iId == null) { throw new NullArgumentException("iId"); }/* w w w .ja v a 2 s . co m*/ List<EntityAndFieldName> lsteafn = new ArrayList<EntityAndFieldName>(); LayoutFacadeLocal layoutFacade = ServerServiceLocator.getInstance().getFacade(LayoutFacadeLocal.class); for (EntityAndFieldName eafn : layoutFacade .getSubFormEntityAndParentSubFormEntityNames(sEntityName, iId, false, customUsage).keySet()) { lsteafn.add(eafn); } return new MasterDataWithDependantsVO(this.get(sEntityName, iId), this.getDependants(iId, lsteafn)); }
From source file:org.nuclos.server.masterdata.ejb3.MasterDataFacadeHelper.java
public void notifyClients(String sCachedEntityName) { if (sCachedEntityName == null) { throw new NullArgumentException("sCachedEntityName"); }/*from ww w . j a v a 2s .com*/ LOG.info("JMS send: notify clients that master data changed:" + this); LocalCachesUtil.getInstance().updateLocalCacheRevalidation(JMSConstants.TOPICNAME_MASTERDATACACHE); NuclosJMSUtils.sendOnceAfterCommitDelayed(sCachedEntityName, JMSConstants.TOPICNAME_MASTERDATACACHE); }
From source file:org.nuclos.server.masterdata.ejb3.MasterDataFacadeHelper.java
/** * gets the dependant master data records for the given entity, using the given foreign key field and the given id as foreign key. * @param sEntityName name of the entity to get all dependant master data records for * @param sForeignKeyField name of the field relating to the foreign entity * @param oRelatedId id by which sEntityName and sParentEntity are related * @return// w w w . j av a 2s.com * @precondition oRelatedId != null * @todo restrict permissions by entity name */ public Collection<EntityObjectVO> getDependantMasterData(String sEntityName, String sForeignKeyField, Object oRelatedId, String username, Map<String, Object> mpParams) { if (oRelatedId == null) { throw new NullArgumentException("oRelatedId"); } LOG.debug("Getting dependant masterdata for entity " + sEntityName + " with foreign key field " + sForeignKeyField + " and related id " + oRelatedId); final MasterDataMetaVO mdmetavo = masterDataMetaCache.getMetaData(sEntityName); Date startDate = new Date(); Collection<MasterDataVO> result = new ArrayList<MasterDataVO>(); if (mdmetavo.isDynamic()) { if (sEntityName.startsWith(MasterDataMetaVO.DYNAMIC_ENTITY_PREFIX)) { String sDataSource = mdmetavo.getDBEntity() .substring(MasterDataMetaVO.DYNAMIC_ENTITY_VIEW_PREFIX.length()).toLowerCase(); try { DatasourceVO datasourceVO = getDatasourceFacade().getDynamicEntity(sDataSource); // @see NUCLOS-654 boolean bIntidCaseInsensitive = true; boolean bIntidGenericObjectCaseInsensitive = true; String sql = getDatasourceFacade().createSQL(datasourceVO.getSource(), new HashMap<String, Object>()); if (sql.toUpperCase().indexOf(" \"INTID\"") != -1) bIntidCaseInsensitive = false; if (sql.toUpperCase().indexOf(" \"INTID_T_UD_GENERICOBJECT\"") != -1) bIntidGenericObjectCaseInsensitive = false; result = getDependantMasterDataForDatasource(oRelatedId, mdmetavo, bIntidCaseInsensitive, bIntidGenericObjectCaseInsensitive); } catch (Exception e) { LOG.warn("getDependantMasterDataForDatasource failed for datasource " + sDataSource, e); } } else if (sEntityName.startsWith(MasterDataMetaVO.CHART_ENTITY_PREFIX)) { String sDataSource = mdmetavo.getDBEntity() .substring(MasterDataMetaVO.CHART_ENTITY_VIEW_PREFIX.length()).toLowerCase(); try { DatasourceVO datasourceVO = getDatasourceFacade().getChart(sDataSource); Map<String, Object> mpTempParams = new HashMap<String, Object>(mpParams); mpTempParams.put("genericObject", oRelatedId); result = getDependantMasterDataForDatasource(oRelatedId, mdmetavo, datasourceVO, mpTempParams); } catch (Exception e) { LOG.warn("getDependantMasterDataForDatasource failed for datasource " + sDataSource, e); } } } else { result = getDependantMasterDataByBean(sEntityName, sForeignKeyField, oRelatedId); } Collection<EntityObjectVO> colEntityObject = CollectionUtils.transform(result, new MasterDataToEntityObjectTransformer(sEntityName)); Date endate = new Date(); NuclosPerformanceLogger.performanceLog(startDate.getTime(), endate.getTime(), username, oRelatedId, sEntityName, "Reading the master data entity for an objekt if type " + sEntityName + " (" + (mdmetavo.isDynamic() ? " dynamic " : " static ") + ")", "", ""); return colEntityObject; }
From source file:org.nuclos.server.masterdata.ejb3.MasterDataFacadeHelper.java
/** * removes a single masterdata row./*from w w w . ja v a 2 s . c o m*/ * @param sEntityName * @param mdvo * @throws CommonFinderException * @throws CommonRemoveException * @throws CommonStaleVersionException * @precondition sEntityName != null */ void removeSingleRow(String sEntityName, final MasterDataVO mdvo) throws CommonFinderException, CommonRemoveException, CommonStaleVersionException, CommonPermissionException { if (sEntityName == null) { throw new NullArgumentException("sEntityName"); } final MasterDataMetaVO mdmetavo = masterDataMetaCache.getMetaData(sEntityName); // prevent removal if dependant dynamic attributes exist: final Object oExternalId = mdvo.getId(); if (oExternalId == null) { throw new NuclosFatalException("mdhelper.error.invalid.id");//"Der Datensatz hat eine leere Id."); } checkForStaleVersion(mdmetavo, mdvo); // @todo refactor: make this easier to write: try { dataBaseHelper.execute( DbStatementUtils.deleteFrom(getUserWritableDbEntityName(mdmetavo), "INTID", mdvo.getIntId())); } catch (CommonFatalException ex) { throw new CommonRemoveException(ex); } //remove documents for (MasterDataMetaFieldVO field : masterDataMetaCache.getMetaData(sEntityName).getFields()) { if (field.getJavaClass().equals(GenericObjectDocumentFile.class)) { String sExtendedPath = ""; if (sEntityName.equals("nuclos_" + NuclosEntity.GENERALSEARCHDOCUMENT)) { GenericObjectDocumentFile docFile = (GenericObjectDocumentFile) mdvo.getField("file"); sExtendedPath = StringUtils.emptyIfNull(docFile.getDirectoryPath()); } File file = new File(NuclosSystemParameters.getString(NuclosSystemParameters.DOCUMENT_PATH) + "/" + sExtendedPath); remove(mdvo.getIntId(), null, NuclosSystemParameters.getDirectory(NuclosSystemParameters.DOCUMENT_PATH)); } } NuclosEntity nucEntity = NuclosEntity.getByName(sEntityName); if (nucEntity != null) switch (nucEntity) { case DBSOURCE: try { updateDbObject(DalSupportForMD.getEntityObjectVO(sEntityName, mdvo), null, false); } catch (NuclosBusinessException e) { throw new CommonRemoveException(e.getMessage(), e); } break; case DBOBJECT: for (EntityObjectVO source : nucletDalProvider.getEntityObjectProcessor(NuclosEntity.DBSOURCE) .getBySearchExpression(appendRecordGrants( new CollectableSearchExpression(SearchConditionUtils.newEOComparison( NuclosEntity.DBSOURCE.getEntityName(), "dbobject", ComparisonOperator.EQUAL, mdvo.getField("name"), MetaDataServerProvider.getInstance())), sEntityName))) this.removeSingleRow(NuclosEntity.DBSOURCE.getEntityName(), DalSupportForMD.wrapEntityObjectVO(source)); break; } this.entityChanged(mdmetavo, mdvo); }
From source file:org.nuclos.server.masterdata.MasterDataWrapper.java
public static MasterDataVO wrapStateModelVO(StateModelVO vo) { byte[] layoutData = null; if (vo.getLayout() == null && vo.getXMLLayout() == null) { throw new NullArgumentException("layoutinfo"); }/* www .j av a 2 s. com*/ try { layoutData = IOUtils.toByteArray(vo.getLayout()); assert layoutData != null; assert layoutData.length > 0; } catch (IOException ex) { throw new NuclosFatalException(ex); } Map<String, Object> mpFields = new HashMap<String, Object>(); mpFields.put("name", vo.getName()); mpFields.put("description", vo.getDescription()); // if(vo.getXMLLayout() != null && vo.getXMLLayout().length() > 0) { // layoutData = vo.getXMLLayout().getBytes(); // } mpFields.put("layout", layoutData); mpFields.put("nucletId", vo.getNucletId()); return new MasterDataVO("<StateModelVO>", vo.getId(), vo.getChangedAt(), vo.getCreatedBy(), vo.getChangedAt(), vo.getChangedBy(), vo.getVersion(), mpFields); }
From source file:org.nuclos.server.masterdata.MasterDataWrapper.java
public static MasterDataVO wrapProcessMonitorVO(ProcessMonitorVO pmVO) { byte[] layoutData = null; if (pmVO.getLayout() == null) { throw new NullArgumentException("layoutinfo"); }// ww w .ja v a2s . com try { layoutData = IOUtils.toByteArray(pmVO.getLayout()); assert layoutData != null; assert layoutData.length > 0; } catch (IOException ex) { throw new NuclosFatalException(ex); } Map<String, Object> mpFields = new HashMap<String, Object>(); mpFields.put("name", pmVO.getName()); mpFields.put("description", pmVO.getDescription()); mpFields.put("layout", layoutData); // ??? return new MasterDataVO(NuclosEntity.PROCESSSTATEMODEL.getEntityName(), pmVO.getId(), pmVO.getChangedAt(), pmVO.getCreatedBy(), pmVO.getChangedAt(), pmVO.getChangedBy(), pmVO.getVersion(), mpFields); }
From source file:org.nuclos.server.masterdata.valueobject.DependantMasterDataMapImpl.java
/** * sets the parent id of masterdata records. * @param iGenericObjectId/*from w ww .ja v a2 s . c o m*/ */ @Override public void setParent(String moduleEntityName, Integer iGenericObjectId, Map<EntityAndFieldName, String> collSubEntities) { if (iGenericObjectId == null) { throw new NullArgumentException("iGenericObjectId"); } Long longId = IdUtils.toLongId(iGenericObjectId); /** @todo eliminate this workaround: */ final MasterDataMetaProvider cache = SpringApplicationContextHolder.getBean(MasterDataMetaProvider.class); for (String sEntityName : this.getEntityNames()) { if (cache != null) { final MasterDataMetaVO mdmetavo = cache.getMetaData(sEntityName); if (mdmetavo.isEditable()) { for (EntityObjectVO mdvo : this.getData(sEntityName)) { String foreignKeyIdField = null; for (EntityAndFieldName entityAndFieldName : collSubEntities.keySet()) { if (entityAndFieldName.getEntityName().equals(sEntityName)) { foreignKeyIdField = entityAndFieldName.getFieldName(); break; } } if (foreignKeyIdField == null) foreignKeyIdField = getForeignKeyField(mdmetavo, moduleEntityName, false); final Long iOldGenericObjectId = mdvo.getFieldId(foreignKeyIdField); if (iOldGenericObjectId != null && !longId.equals(iOldGenericObjectId)) { log.warn("Bad parent id in dependant masterdata record; old id: " + iOldGenericObjectId + ", new id: " + longId + "."); } if (iOldGenericObjectId == null || (!longId.equals(iOldGenericObjectId) && mdvo.isFlagUpdated())) { mdvo.getFieldIds().put(foreignKeyIdField, longId); } } } } } }
From source file:org.nuclos.server.masterdata.valueobject.MasterDataMetaVO.java
/** * constructor to be called by server only * @param iId primary key of underlying database record * @param sEntityName name of master data entity * @param sDBEntityName name of underlying table * @param sMenuPath menu path of underlying table * @param bSearchable should a search screen be shown? * @param bEditable should screen be editable * @param sLabel label of master data entity * @param dateCreatedAt creation date of underlying database record * @param sCreatedBy creator of underlying database record * @param dateChangedAt last changed date of underlying database record * @param sChangedBy last changer of underlying database record * @precondition sEntityName != null/*from w w w .j av a 2 s . c o m*/ */ public MasterDataMetaVO(Integer iId, String sEntityName, String sDBEntityName, String sMenuPath, boolean bSearchable, boolean bEditable, String sLabel, Collection<String> collFieldsForEquality, boolean bCacheable, java.util.Date dateCreatedAt, String sCreatedBy, java.util.Date dateChangedAt, String sChangedBy, Integer iVersion, Map<String, ? extends MasterDataMetaFieldVO> mpFields, String sTreeView, String sDescription, boolean bSystemEntity, String sResourceName, String sNuclosResource, boolean bImportExport, String sLabelPlural, Integer iAccModifier, String accelerator, String sResourceIdForLabel, String sResourceIdForMenuPath, String sResourceIdForLabelPlural, String sResourceIdForTreeView, String sResourceIdForTreeViewDescription) { super(iId, dateCreatedAt, sCreatedBy, dateChangedAt, sChangedBy, iVersion); if (sEntityName == null) { throw new NullArgumentException("sEntityName"); } this.sEntityName = sEntityName; this.sDBEntityName = sDBEntityName; this.sMenuPath = sMenuPath; this.bSearchable = bSearchable; this.bEditable = bEditable; this.sLabel = sLabel; this.mpFields = mpFields; this.bDynamic = false; this.collFieldsForEquality = CollectionUtils.<String>emptyIfNull(collFieldsForEquality); this.bCacheable = bCacheable; this.sTreeView = sTreeView; this.sDescription = sDescription; this.bSystemEntity = bSystemEntity; this.sResourceName = sResourceName; this.sNuclosResource = sNuclosResource; this.bImportExport = bImportExport; this.sLabelPlural = sLabelPlural; this.iAcceleratorModifier = iAccModifier; this.sAccelerator = accelerator; this.sResourceIdForLabel = sResourceIdForLabel; this.sResourceIdForLabelPlural = sResourceIdForLabelPlural; this.sResourceIdForMenuPath = sResourceIdForMenuPath; this.sResourceIdForTreeView = sResourceIdForTreeView; this.sResourceIdForTreeViewDescription = sResourceIdForTreeViewDescription; }