Пример #1
0
  @Override
  public CommandSource handleCommandForCheckerApproval(final CommandSource commandSourceResult) {

    final AppUser checker = context.authenticatedUser();

    Long resourceId = commandSourceResult.resourceId();
    final UserCommand command =
        this.commandDeserializerService.deserializeUserCommand(
            resourceId, commandSourceResult.json(), true);
    if (commandSourceResult.isUserResource()) {
      if (commandSourceResult.isCreate()) {
        final List<String> allowedPermissions =
            Arrays.asList("ALL_FUNCTIONS", "USER_ADMINISTRATION_SUPER_USER", "CREATE_USER_MAKER");
        context
            .authenticatedUser()
            .validateHasPermissionTo("CREATE_USER_MAKER", allowedPermissions);

        resourceId = this.writePlatformService.createUser(command);
        commandSourceResult.updateResourceId(resourceId);
        commandSourceResult.markAsChecked(checker, new LocalDate());
      } else if (commandSourceResult.isUpdate()) {
        final List<String> allowedPermissions =
            Arrays.asList("ALL_FUNCTIONS", "USER_ADMINISTRATION_SUPER_USER", "UPDATE_USER_MAKER");
        context
            .authenticatedUser()
            .validateHasPermissionTo("UPDATE_USER_MAKER", allowedPermissions);

        if (checker.hasIdOf(command.getId())) {
          this.writePlatformService.updateUsersOwnAccountDetails(command);
        } else {
          this.writePlatformService.updateUser(command);
        }

        commandSourceResult.markAsChecked(checker, new LocalDate());
      } else if (commandSourceResult.isDelete()) {
        final List<String> allowedPermissions =
            Arrays.asList("ALL_FUNCTIONS", "USER_ADMINISTRATION_SUPER_USER", "DELETE_USER_MAKER");
        context
            .authenticatedUser()
            .validateHasPermissionTo("DELETE_USER_MAKER", allowedPermissions);

        this.writePlatformService.deleteUser(command);
        commandSourceResult.markAsChecked(checker, new LocalDate());
      }
    }

    return commandSourceResult;
  }
Пример #2
0
  @GET
  @Path("{taxMapId}")
  @Consumes({MediaType.APPLICATION_JSON})
  @Produces({MediaType.APPLICATION_JSON})
  public String retrievedSingleTaxMap(
      @PathParam("taxMapId") final Long taxMapId, @Context final UriInfo uriInfo) {

    context.authenticatedUser().validateHasReadPermission(resourceNameForPermissions);
    TaxMapData taxMapData = taxMapReadPlatformService.retrievedSingleTaxMapData(taxMapId);
    final ApiRequestJsonSerializationSettings settings =
        apiRequestParameterHelper.process(uriInfo.getQueryParameters());
    if (settings.isTemplate()) {
      final List<ChargeCodeData> chargeCodeData =
          this.taxMapReadPlatformService.retrivedChargeCodeTemplateData();
      final Collection<MCodeData> taxTypeData =
          this.mCodeReadPlatformService.getCodeValue(CodeNameConstants.CODE_TYPE);
      final List<PriceRegionData> priceRegionData =
          this.regionalPriceReadplatformService.getPriceRegionsDetails();
      taxMapData.setChargeCodesForTax(chargeCodeData);
      taxMapData.setTaxTypeData(taxTypeData);
      taxMapData.setPriceRegionData(priceRegionData);
      taxMapData.setDate(DateUtils.getLocalDateOfTenantForClient());
    }
    return this.apiJsonSerializer.serialize(settings, taxMapData, RESPONSE_TAXMAPPING_PARAMETERS);
  }
  @Transactional
  @Override
  public CommandProcessingResult createOffice(final JsonCommand command) {

    try {
      final AppUser currentUser = context.authenticatedUser();

      this.fromApiJsonDeserializer.validateForCreate(command.json());

      Long parentId = null;
      if (command.parameterExists("parentId")) {
        parentId = command.longValueOfParameterNamed("parentId");
      }

      final Office parent = validateUserPriviledgeOnOfficeAndRetrieve(currentUser, parentId);
      final Office office = Office.fromJson(parent, command);

      // pre save to generate id for use in office hierarchy
      this.officeRepository.save(office);

      office.generateHierarchy();

      this.officeRepository.save(office);

      return new CommandProcessingResultBuilder() //
          .withCommandId(command.commandId()) //
          .withEntityId(office.getId()) //
          .withOfficeId(office.getId()) //
          .build();
    } catch (DataIntegrityViolationException dve) {
      handleOfficeDataIntegrityIssues(command, dve);
      return CommandProcessingResult.empty();
    }
  }
  @Transactional
  @Override
  public EntityIdentifier closeAsRescheduled(final LoanTransactionCommand command) {
    context.authenticatedUser();

    final LoanTransactionCommandValidator validator = new LoanTransactionCommandValidator(command);
    validator.validateNonMonetaryTransaction();

    final Loan loan = this.loanRepository.findOne(command.getLoanId());
    if (loan == null) {
      throw new LoanNotFoundException(command.getLoanId());
    }

    loan.closeAsMarkedForReschedule(
        command.getTransactionDate(), defaultLoanLifecycleStateMachine());

    this.loanRepository.save(loan);

    final String noteText = command.getNote();
    if (StringUtils.isNotBlank(noteText)) {
      final Note note = Note.loanNote(loan, noteText);
      this.noteRepository.save(note);
    }

    return new EntityIdentifier(loan.getId());
  }
  @Transactional
  @Override
  public EntityIdentifier waiveInterestOnLoan(final LoanTransactionCommand command) {

    context.authenticatedUser();

    final LoanTransactionCommandValidator validator = new LoanTransactionCommandValidator(command);
    validator.validate();

    final Loan loan = this.loanRepository.findOne(command.getLoanId());
    if (loan == null) {
      throw new LoanNotFoundException(command.getLoanId());
    }

    final LoanTransaction waiveTransaction =
        loan.waiveInterest(
            command.getTransactionAmount(),
            command.getTransactionDate(),
            defaultLoanLifecycleStateMachine());

    this.loanTransactionRepository.save(waiveTransaction);
    this.loanRepository.save(loan);

    final String noteText = command.getNote();
    if (StringUtils.isNotBlank(noteText)) {
      final Note note = Note.loanTransactionNote(loan, waiveTransaction, noteText);
      this.noteRepository.save(note);
    }

    return new EntityIdentifier(loan.getId());
  }
  @Transactional
  @Override
  public EntityIdentifier disburseLoan(final Long loanId, final JsonCommand command) {

    final AppUser currentUser = context.authenticatedUser();

    final LoanStateTransitionCommand disburseLoan =
        this.loanStateTransitionCommandFromApiJsonDeserializer.commandFromApiJson(command.json());
    disburseLoan.validate();

    final Loan loan = retrieveLoanBy(loanId);

    final String noteText = command.stringValueOfParameterNamed("note");
    final LocalDate actualDisbursementDate = disburseLoan.getDisbursedOnDate();
    if (this.isBeforeToday(actualDisbursementDate) && currentUser.canNotDisburseLoanInPast()) {
      throw new NoAuthorizationException(
          "User has no authority to disburse loan with a date in the past.");
    }

    final ApplicationCurrency currency =
        this.applicationCurrencyRepository.findOneByCode(loan.getPrincpal().getCurrencyCode());

    final Map<String, Object> changes =
        loan.disburse(command, defaultLoanLifecycleStateMachine(), currency);
    this.loanRepository.save(loan);

    if (StringUtils.isNotBlank(noteText)) {
      Note note = Note.loanNote(loan, noteText);
      this.noteRepository.save(note);
    }

    return EntityIdentifier.resourceResult(loanId, command.commandId(), changes);
  }
  @Transactional
  @Override
  public EntityIdentifier applicantWithdrawsFromLoanApplication(
      final Long loanId, final JsonCommand command) {

    final AppUser currentUser = context.authenticatedUser();

    final LoanStateTransitionCommand applicantWithdrawsFromLoanApplication =
        this.loanStateTransitionCommandFromApiJsonDeserializer.commandFromApiJson(command.json());
    applicantWithdrawsFromLoanApplication.validate();

    final Loan loan = retrieveLoanBy(loanId);

    final LocalDate eventDate = applicantWithdrawsFromLoanApplication.getWithdrawnOnDate();
    if (this.isBeforeToday(eventDate) && currentUser.canNotWithdrawByClientLoanInPast()) {
      throw new NoAuthorizationException(
          "User has no authority to mark loan as withdrawn by applicant with a date in the past.");
    }

    final Map<String, Object> changes =
        loan.loanApplicationWithdrawnByApplicant(command, defaultLoanLifecycleStateMachine());
    this.loanRepository.save(loan);

    String noteText = command.stringValueOfParameterNamed("note");
    if (StringUtils.isNotBlank(noteText)) {
      Note note = Note.loanNote(loan, noteText);
      this.noteRepository.save(note);
    }

    return EntityIdentifier.resourceResult(loanId, command.commandId(), changes);
  }
  /**
   * This method <code>retrieveMessageTemplate</code> used for Retrieving the Particular Message
   * Template with it's Parameters.
   *
   * @param messageId id of the MessageTemplate
   * @param uriInfo Containing Url information
   * @return
   */
  @GET
  @Path("{messageId}")
  @Consumes({MediaType.APPLICATION_JSON})
  @Produces({MediaType.APPLICATION_JSON})
  public String retrieveMessageTemplate(
      @PathParam("messageId") final Long messageId, @Context final UriInfo uriInfo) {

    context.authenticatedUser().validateHasReadPermission(resourceNameForPermissions);

    final List<BillingMessageTemplateData> messageParams =
        this.billingMesssageReadPlatformService.retrieveMessageParams(messageId);

    final BillingMessageTemplateData messageType =
        this.billingMesssageReadPlatformService.retrieveTemplate();

    final BillingMessageTemplateData templateData =
        this.billingMesssageReadPlatformService.retrieveMessageTemplate(messageId);
    templateData.setMessageParams(messageParams);
    templateData.setMessageType(messageType.getMessageTypes());

    final ApiRequestJsonSerializationSettings settings =
        apiRequestParameterHelper.process(uriInfo.getQueryParameters());

    return this.toApiJsonSerializer.serialize(settings, templateData, RESPONSE_PARAMETERS);
  }
  @Override
  public CommandProcessingResult updateProspect(JsonCommand command) {

    try {
      context.authenticatedUser();
      this.clientProspectCommandFromApiJsonDeserializer.validateForCreate(command.json());

      final ClientProspect pros = retrieveCodeBy(command.entityId());
      final Map<String, Object> changes = pros.update(command);

      if (!changes.isEmpty()) {
        this.clientProspectJpaRepository.save(pros);
      }

      return new CommandProcessingResultBuilder() //
          .withCommandId(command.commandId()) //
          .withEntityId(pros.getId()) //
          .with(changes) //
          .build();

    } catch (DataIntegrityViolationException dve) {
      handleDataIntegrityIssues(command, dve);
    }
    return new CommandProcessingResultBuilder().withEntityId(-1L).build();
  }
  @Transactional
  @Override
  public EntityIdentifier updateRolePermissions(final Long roleId, final JsonCommand command) {
    context.authenticatedUser();

    final Role role = this.roleRepository.findOne(roleId);
    if (role == null) {
      throw new RoleNotFoundException(roleId);
    }

    final Collection<Permission> allPermissions = this.permissionRepository.findAll();

    final PermissionsCommand permissionsCommand =
        this.permissionsFromApiJsonDeserializer.commandFromApiJson(command.json());

    final Map<String, Boolean> commandPermissions = permissionsCommand.getPermissions();
    final Map<String, Object> changes = new HashMap<String, Object>();
    final Map<String, Boolean> changedPermissions = new HashMap<String, Boolean>();
    for (final String permissionCode : commandPermissions.keySet()) {
      final boolean isSelected = commandPermissions.get(permissionCode).booleanValue();

      final Permission permission = findPermissionByCode(allPermissions, permissionCode);
      boolean changed = role.updatePermission(permission, isSelected);
      if (changed) {
        changedPermissions.put(permissionCode, isSelected);
      }
    }

    if (!changedPermissions.isEmpty()) {
      changes.put("permissions", changedPermissions);
      this.roleRepository.save(role);
    }

    return EntityIdentifier.withChanges(role.getId(), changes);
  }
  @Override
  public Page<AddressLocationDetails> retrieveAllAddressLocations(
      final SearchSqlQuery searchAddresses) {
    try {
      context.authenticatedUser();
      final AddressLocationMapper locationMapper = new AddressLocationMapper();

      final StringBuilder sqlBuilder = new StringBuilder(200);
      sqlBuilder.append("select ");
      sqlBuilder.append(locationMapper.schema());
      String sqlSearch = searchAddresses.getSqlSearch();
      String extraCriteria = "";
      if (sqlSearch != null) {
        sqlSearch = sqlSearch.trim();
        extraCriteria = "  where country_name like '%" + sqlSearch + "%' ";
      }

      sqlBuilder.append(extraCriteria);

      if (searchAddresses.isLimited()) {
        sqlBuilder.append(" limit ").append(searchAddresses.getLimit());
      }
      if (searchAddresses.isOffset()) {
        sqlBuilder.append(" offset ").append(searchAddresses.getOffset());
      }
      return this.paginationHelper.fetchPage(
          this.jdbcTemplate,
          "SELECT FOUND_ROWS()",
          sqlBuilder.toString(),
          new Object[] {},
          locationMapper);
    } catch (final EmptyResultDataAccessException e) {
      return null;
    }
  }
  @Transactional
  @Override
  public void updateMakerCheckerPermissions(final PermissionsCommand command) {
    context.authenticatedUser();

    final Collection<Permission> allPermissions = this.permissionRepository.findAll();

    final Map<String, Boolean> commandPermissions = command.getPermissions();
    for (final String permissionCode : commandPermissions.keySet()) {

      final Permission permission = findPermissionByCode(allPermissions, permissionCode);

      if (permission.getCode().endsWith("_CHECKER")
          || permission.getCode().startsWith("READ_")
          || permission.getGrouping().equalsIgnoreCase("special")) {
        throw new PermissionNotFoundException(permissionCode);
      }

      final boolean isSelected = commandPermissions.get(permissionCode).booleanValue();
      permission.enableMakerChecker(isSelected);

      this.permissionRepository.save(permission);

      // Typical rollback if maker-checker enabled not here - does it make sense to have a maker
      // checker task for enabling maker-checker for other tasks?
    }
  }
  @Transactional
  @Override
  public EntityIdentifier submitLoanApplication(final JsonCommand command) {

    context.authenticatedUser();

    LoanApplicationCommand loanApplicationCommand =
        this.fromApiJsonDeserializer.commandFromApiJson(command.json());
    loanApplicationCommand.validate();

    CalculateLoanScheduleQuery calculateLoanScheduleQuery =
        this.calculateLoanScheduleQueryFromApiJsonDeserializer.commandFromApiJson(command.json());
    calculateLoanScheduleQuery.validate();

    final Loan newLoanApplication = loanAssembler.assembleFrom(command);

    this.loanRepository.save(newLoanApplication);

    final String submittedOnNote = command.stringValueOfParameterNamed("submittedOnNote");
    if (StringUtils.isNotBlank(submittedOnNote)) {
      Note note = Note.loanNote(newLoanApplication, submittedOnNote);
      this.noteRepository.save(note);
    }

    return EntityIdentifier.resourceResult(newLoanApplication.getId(), command.commandId());
  }
  @Transactional
  @Override
  public CommandProcessingResult followUpProspect(
      final JsonCommand command, final Long prospectId) {
    try {
      context.authenticatedUser();
      this.clientProspectCommandFromApiJsonDeserializer.validateForUpdate(command.json());

      final ProspectDetail prospectDetail = ProspectDetail.fromJson(command, prospectId);
      prospectDetailJpaRepository.save(prospectDetail);

      return new CommandProcessingResultBuilder()
          .withCommandId(command.commandId())
          .withEntityId(prospectDetail.getProspectId())
          .build();

    } catch (DataIntegrityViolationException dve) {
      handleDataIntegrityIssues(command, dve);
      return CommandProcessingResult.empty();
    } catch (ParseException e) {
      throw new PlatformDataIntegrityException(
          "invalid.date.and.time.format",
          "invalid.date.and.time.format",
          "invalid.date.and.time.format");
    }
  }
  @Transactional
  @Override
  public CommandProcessingResult createProspect(JsonCommand command) {

    try {
      context.authenticatedUser();
      this.clientProspectCommandFromApiJsonDeserializer.validateForCreate(command.json());

      final ClientProspect entity = ClientProspect.fromJson(fromApiJsonHelper, command);
      this.clientProspectJpaRepository.save(entity);

      return new CommandProcessingResultBuilder()
          .withCommandId(command.commandId())
          .withEntityId(entity.getId())
          .build();

    } catch (DataIntegrityViolationException dve) {
      handleDataIntegrityIssues(command, dve);
      return new CommandProcessingResult(Long.valueOf(-1));
    } catch (ParseException pe) {
      throw new PlatformDataIntegrityException(
          "invalid.date.and.time.format",
          "invalid.date.and.time.format",
          "invalid.date.and.time.format");
    }
  }
  @Override
  public List<AddressData> retrieveCityDetails(final String selectedname) {
    context.authenticatedUser();
    final DataMapper mapper = new DataMapper();

    final String sql = "select " + mapper.schema(selectedname);

    return this.jdbcTemplate.query(sql, mapper, new Object[] {});
  }
  @Override
  public List<String> retrieveCityDetails() {
    context.authenticatedUser();
    final AddressMapper1 mapper = new AddressMapper1();

    final String sql = "select " + mapper.sqlschema("city_name", "city") + " where is_delete = 'N'";

    return this.jdbcTemplate.query(sql, mapper, new Object[] {});
  }
  @Override
  public List<String> retrieveStateDetails() {
    context.authenticatedUser();
    final AddressMapper1 mapper = new AddressMapper1();

    final String sql = "select " + mapper.sqlschema("state_name", "state");

    return this.jdbcTemplate.query(sql, mapper, new Object[] {});
  }
  @Override
  public List<AddressData> retrieveAddressDetails() {

    context.authenticatedUser();
    final AddressMapper mapper = new AddressMapper();

    final String sql = "select " + mapper.schema() + " where is_deleted='n'";

    return this.jdbcTemplate.query(sql, mapper, new Object[] {});
  }
  @GET
  @Path("{productId}")
  @Consumes({MediaType.APPLICATION_JSON})
  @Produces({MediaType.APPLICATION_JSON})
  public String retrieveSavingProductDetails(
      @PathParam("productId") final Long productId, @Context final UriInfo uriInfo) {

    context.authenticatedUser().validateHasReadPermission(entityType);

    Set<String> typicalResponseParameters =
        new HashSet<String>(
            Arrays.asList(
                "id",
                "createdOn",
                "lastModifedOn",
                "locale",
                "name",
                "description",
                "currencyCode",
                "digitsAfterDecimal",
                "interstRate",
                "minInterestRate",
                "maxInterestRate",
                "savingsDepositAmount",
                "savingProductType",
                "tenureType",
                "tenure",
                "frequency",
                "interestType",
                "interestCalculationMethod",
                "minimumBalanceForWithdrawal",
                "isPartialDepositAllowed",
                "isLockinPeriodAllowed",
                "lockinPeriod",
                "lockinPeriodType",
                "depositEvery"));

    Set<String> responseParameters =
        ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
    if (responseParameters.isEmpty()) {
      responseParameters.addAll(typicalResponseParameters);
    }

    SavingProductData savingProduct =
        this.savingProductReadPlatformService.retrieveSavingProduct(productId);

    boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
    boolean template = ApiParameterHelper.template(uriInfo.getQueryParameters());
    if (template) {
      savingProduct = handleTemplateRelatedData(responseParameters, savingProduct);
    }

    return this.apiJsonSerializerService.serializeSavingProductDataToJson(
        prettyPrint, responseParameters, savingProduct);
  }
 @GET
 @Path("mediadata")
 @Consumes({MediaType.APPLICATION_JSON})
 @Produces({MediaType.APPLICATION_JSON})
 public String retrieveAllMediaAssestdata(@Context final UriInfo uriInfo) {
   context.authenticatedUser().validateHasReadPermission(resourceNameForPermissions);
   List<MediaAssetData> data = this.mediaAssetReadPlatformService.retrieveAllAssetdata();
   final ApiRequestJsonSerializationSettings settings =
       apiRequestParameterHelper.process(uriInfo.getQueryParameters());
   return this.toApiJsonSerializer.serialize(settings, data, RESPONSE_DATA_PARAMETERS);
 }
 @Override
 public CommandProcessingResult deleteAsset(JsonCommand command) {
   context.authenticatedUser();
   final MediaAsset mediaAsset = retriveMessageBy(command.entityId());
   if (mediaAsset == null) {
     throw new DataIntegrityViolationException(mediaAsset.toString());
   }
   mediaAsset.isDelete();
   this.assetRepository.save(mediaAsset);
   return new CommandProcessingResult(mediaAsset.getId());
 }
  @Transactional
  @Override
  @Caching(
      evict = {
        @CacheEvict(
            value = "offices",
            key =
                "T(org.mifosplatform.infrastructure.core.service.ThreadLocalContextUtil).getTenant().getTenantIdentifier().concat(#root.target.context.authenticatedUser().getOffice().getHierarchy()+'of')"),
        @CacheEvict(
            value = "officesForDropdown",
            key =
                "T(org.mifosplatform.infrastructure.core.service.ThreadLocalContextUtil).getTenant().getTenantIdentifier().concat(#root.target.context.authenticatedUser().getOffice().getHierarchy()+'ofd')"),
        @CacheEvict(
            value = "officesById",
            key =
                "T(org.mifosplatform.infrastructure.core.service.ThreadLocalContextUtil).getTenant().getTenantIdentifier().concat(#officeId)")
      })
  public CommandProcessingResult updateOffice(final Long officeId, final JsonCommand command) {

    try {
      final AppUser currentUser = context.authenticatedUser();

      this.fromApiJsonDeserializer.validateForUpdate(command.json());

      Long parentId = null;
      if (command.parameterExists("parentId")) {
        parentId = command.longValueOfParameterNamed("parentId");
      }

      final Office office = validateUserPriviledgeOnOfficeAndRetrieve(currentUser, officeId);

      final Map<String, Object> changes = office.update(command);

      if (changes.containsKey("parentId")) {
        final Office parent = validateUserPriviledgeOnOfficeAndRetrieve(currentUser, parentId);
        office.update(parent);
      }

      if (!changes.isEmpty()) {
        this.officeRepository.saveAndFlush(office);
      }

      return new CommandProcessingResultBuilder() //
          .withCommandId(command.commandId()) //
          .withEntityId(office.getId()) //
          .withOfficeId(office.getId()) //
          .with(changes) //
          .build();
    } catch (DataIntegrityViolationException dve) {
      handleOfficeDataIntegrityIssues(command, dve);
      return CommandProcessingResult.empty();
    }
  }
  @Override
  public List<CityDetailsData> retrieveCitywithCodeDetails() {

    try {
      context.authenticatedUser();
      final CityMapper mapper = new CityMapper();
      final String sql = "select " + mapper.schema();
      return this.jdbcTemplate.query(sql, mapper, new Object[] {});
    } catch (final EmptyResultDataAccessException e) {
      return null;
    }
  }
Пример #25
0
  @Override
  public CommandSource handleCommandWithSupportForRollback(final CommandSource commandSource) {

    final AppUser maker = context.authenticatedUser();
    final LocalDate asToday = new LocalDate();

    final Long resourceId = commandSource.resourceId();
    final UserCommand command =
        this.commandDeserializerService.deserializeUserCommand(
            resourceId, commandSource.json(), false);

    CommandSource commandSourceResult = commandSource.copy();
    if (commandSource.isCreate()) {
      try {
        Long newResourceId = this.writePlatformService.createUser(command);

        commandSourceResult.markAsChecked(maker, asToday);
        commandSourceResult.updateResourceId(newResourceId);
      } catch (RollbackTransactionAsCommandIsNotApprovedByCheckerException e) {
        // swallow this rollback transaction by design
      }
    } else if (commandSource.isUpdate()) {
      try {
        final String jsonOfChangesOnly =
            this.changeDetectionService.detectChangesOnUpdate(
                commandSource.resourceName(), commandSource.resourceId(), commandSource.json());
        commandSourceResult.updateJsonTo(jsonOfChangesOnly);

        final UserCommand changesOnly =
            this.commandDeserializerService.deserializeUserCommand(
                resourceId, jsonOfChangesOnly, false);

        if (maker.hasIdOf(command.getId())) {
          this.writePlatformService.updateUsersOwnAccountDetails(changesOnly);
        } else {
          this.writePlatformService.updateUser(changesOnly);
        }

        commandSourceResult.markAsChecked(maker, asToday);
      } catch (RollbackTransactionAsCommandIsNotApprovedByCheckerException e) {
        // swallow this rollback transaction by design
      }
    } else if (commandSource.isDelete()) {
      try {
        this.writePlatformService.deleteUser(command);
        commandSourceResult.markAsChecked(maker, asToday);
      } catch (RollbackTransactionAsCommandIsNotApprovedByCheckerException e) {
        // swallow this rollback transaction by design
      }
    }

    return commandSourceResult;
  }
Пример #26
0
  @GET
  @Consumes({MediaType.APPLICATION_JSON})
  @Produces({MediaType.APPLICATION_JSON})
  public String retrieveAllCharges(@Context final UriInfo uriInfo) {

    context.authenticatedUser().validateHasReadPermission(resourceNameForPermissions);

    final Collection<ChargeData> charges = this.readPlatformService.retrieveAllCharges();

    final ApiRequestJsonSerializationSettings settings =
        apiRequestParameterHelper.process(uriInfo.getQueryParameters());
    return this.toApiJsonSerializer.serialize(settings, charges, CHARGES_DATA_PARAMETERS);
  }
Пример #27
0
  @GET
  @Path("{chargCode}/chargetax")
  @Consumes({MediaType.APPLICATION_JSON})
  @Produces({MediaType.APPLICATION_JSON})
  public String retriveTaxDetailsForChargeCode(
      @PathParam("chargCode") final String chargeCode, @Context final UriInfo uriInfo) {

    context.authenticatedUser().validateHasReadPermission(resourceNameForPermissions);
    final List<TaxMapData> taxMapData = taxMapReadPlatformService.retriveTaxMapData(chargeCode);
    final ApiRequestJsonSerializationSettings settings =
        apiRequestParameterHelper.process(uriInfo.getQueryParameters());
    return this.apiJsonSerializer.serialize(settings, taxMapData, RESPONSE_TAXMAPPING_PARAMETERS);
  }
  @Override
  public List<AddressData> retrieveClientAddressDetails(final Long clientId) {
    try {
      context.authenticatedUser();
      final AddressMapper mapper = new AddressMapper();

      final String sql = "select " + mapper.schema() + " where a.is_deleted='n' and a.client_id=?";

      return this.jdbcTemplate.query(sql, mapper, new Object[] {clientId});
    } catch (final EmptyResultDataAccessException e) {
      return null;
    }
  }
  @GET
  @Path("template")
  @Consumes({MediaType.APPLICATION_JSON})
  @Produces({MediaType.APPLICATION_JSON})
  public String retrieveMediaAssestTemplatedata(@Context final UriInfo uriInfo) {
    context.authenticatedUser().validateHasReadPermission(resourceNameForPermissions);

    MediaAssetData assetData = handleTEmplateData();

    final ApiRequestJsonSerializationSettings settings =
        apiRequestParameterHelper.process(uriInfo.getQueryParameters());
    return this.toApiJsonSerializer.serialize(settings, assetData, RESPONSE_DATA_PARAMETERS);
  }
  @Transactional
  @Override
  public CommandProcessingResult deleteOfficeTransaction(
      final Long transactionId, JsonCommand command) {

    context.authenticatedUser();

    this.officeTransactionRepository.delete(transactionId);

    return new CommandProcessingResultBuilder() //
        .withCommandId(command.commandId()) //
        .withEntityId(transactionId) //
        .build();
  }