Gets the LedgerMetadata for the ledger with given ledger Id.

@param ledgerId The Ledger Id to search.
@return The sought LedgerMetadata, or null if not found.
347274
LedgerMetadata getLedger(long ledgerId) {
        int index = getLedgerMetadataIndex(ledgerId);
        if (index >= 0) {
            return this.ledgers.get(index);
        }

        return null;
    }
1206153
public Attachment getAttachmentMetaData(String assetId, String attachmentId) throws IOException, BadVersionException, RequestFailureException {
        // At the moment can only get all attachments
        Asset ass = getAsset(assetId);
        List<Attachment> allAttachments = ass.getAttachments();
        for (Attachment attachment : allAttachments) {
            if (attachmentId.equals(attachment.get_id())) {
                return attachment;
            }
        }

        // Didn't find it so just return null
        return null;
    }
140226
public byte[] getFrameData(String id)
	{
		if (frames.containsKey(id))
		{
			return ((ID3v2Frame) frames.get(id)).getFrameData();
		}

		return null;
	}
840067
LogMetadata removeEmptyLedgers(int skipCountFromEnd) {
        val newLedgers = new ArrayList<LedgerMetadata>();
        int cutoffIndex = this.ledgers.size() - skipCountFromEnd;
        for (int i = 0; i < cutoffIndex; i++) {
            LedgerMetadata lm = this.ledgers.get(i);
            if (lm.getStatus() != LedgerMetadata.Status.Empty) {
                // Not Empty or Unknown: keep it!
                newLedgers.add(lm);
            }
        }

        // Add the ones from the end, as instructed.
        for (int i = cutoffIndex; i < this.ledgers.size(); i++) {
            newLedgers.add(this.ledgers.get(i));
        }

        return new LogMetadata(this.epoch, this.enabled, Collections.unmodifiableList(newLedgers), this.truncationAddress, this.updateVersion.get());
    }
476230
public final EntityMetadata getEntityMetadata() {
        EntityMetadata metadata = null;
        try {
            metadata = KunderaMetadataManager.getEntityMetadata(kunderaMetadata, entityClass);
        } catch (KunderaException e) {
            logger.info("No Entity class provided, Proceeding as Scalar Query");
        }
        if (!this.isNativeQuery && metadata == null) {
            throw new KunderaException("Unable to load entity metadata for : " + entityClass);
        }
        return metadata;
    }
604769
public static String getDataName(String moduleName, int dataId) {
        PmiModuleConfig config = PerfModules.getConfig(moduleName);
        if (config == null)
            return null;

        PmiDataInfo info = config.getDataInfo(dataId);
        if (info == null)
            return null;
        else
            return info.getName();
    }
1154589
@Override
    public JsonDocument getDocumentFromEntity(EntityMetadata entityMetadata, Object entity,
            KunderaMetadata kunderaMetadata)
    {

        MetamodelImpl metaModel = (MetamodelImpl) kunderaMetadata.getApplicationMetadata()
                .getMetamodel(entityMetadata.getPersistenceUnit());
        Class entityClazz = entityMetadata.getEntityClazz();
        EntityType entityType = metaModel.entity(entityClazz);
        Set<Attribute> attributes = entityType.getAttributes();
        Iterator<Attribute> iterator = attributes.iterator();
        JsonObject obj = iterateAndPopulateJsonObject(entity, iterator, entityMetadata.getTableName());
        Object id = PropertyAccessorHelper.getId(entity, entityMetadata);
        return JsonDocument.create(entityMetadata.getTableName() + CouchbaseConstants.ID_SEPARATOR + id.toString(),
                obj);
    }
816727
public Message getMessage(MessageId id)
  {
    // Performance note: this method uses a lazy initialization pattern. When
    // a MessageId is first requested, we fetch the data from the ResourceBundle
    // and create a new Message object, which is then cached. On the next 
    // request, we'll use the cached version instead. 
    Message message;
    if (cachedMessages.containsKey(id))
    {
      message = cachedMessages.get(id);
    } 
    else
    {
      message = new Message(id, defaultSeverities.get(id), getMessageAsString(id), getSuggestion(id));
      cachedMessages.put(id, message);
    }

    return message;
  }
12750
public static RequestMetadata getRequestMetadata() {
        RequestMetadata metadata = threadLocal.get();
        if (metadata == null)
            metadata = getNoMetadata();
        return metadata;
    }
824282
public Transaction findByTransactionId(String transactionId) {
        EntityManager entityManager = getEntityManager();
        try {
            return entityManager.createQuery("SELECT t FROM io.motown.operatorapi.viewmodel.persistence.entities.Transaction AS t WHERE t.transactionId = :transactionId", Transaction.class)
                    .setParameter("transactionId", transactionId)
                    .getSingleResult();
        } finally {
            entityManager.close();
        }
    }
1231966
@SneakyThrows
    @SuppressFBWarnings("PRMC_POSSIBLY_REDUNDANT_METHOD_CALLS")
    public static MetadataResolver getMetadataResolverForAllSamlServices(final ServicesManager servicesManager,
                                                                         final String entityID,
                                                                         final SamlRegisteredServiceCachingMetadataResolver resolver) {

        val registeredServices = servicesManager.findServiceBy(SamlRegisteredService.class::isInstance);
        val chainingMetadataResolver = new ChainingMetadataResolver();

        val resolvers = registeredServices.stream()
            .filter(SamlRegisteredService.class::isInstance)
            .map(SamlRegisteredService.class::cast)
            .map(s -> SamlRegisteredServiceServiceProviderMetadataFacade.get(resolver, s, entityID))
            .filter(Optional::isPresent)
            .map(Optional::get)
            .map(SamlRegisteredServiceServiceProviderMetadataFacade::getMetadataResolver)
            .collect(Collectors.toList());

        LOGGER.debug("Located [{}] metadata resolvers to match against [{}]", resolvers, entityID);

        chainingMetadataResolver.setResolvers(resolvers);
        chainingMetadataResolver.setId(entityID);
        chainingMetadataResolver.initialize();
        return chainingMetadataResolver;
    }
665503
def handle_get_txn_req(self, request: Request, frm: str):
        
        ledger_id = request.operation.get(f.LEDGER_ID.nm, DOMAIN_LEDGER_ID)
        if ledger_id not in self.ledger_to_req_handler:
            self.send_nack_to_client((request.identifier, request.reqId),
                                     'Invalid ledger id {}'.format(ledger_id),
                                     frm)
            return

        seq_no = request.operation.get(DATA)
        self.send_ack_to_client((request.identifier, request.reqId), frm)
        ledger = self.getLedger(ledger_id)

        try:
            txn = self.getReplyFromLedger(ledger, seq_no)
        except KeyError:
            txn = None

        if txn is None:
            logger.debug(
                "{} can not handle GET_TXN request: ledger doesn't "
                "have txn with seqNo={}".format(self, str(seq_no)))

        result = {
            f.IDENTIFIER.nm: request.identifier,
            f.REQ_ID.nm: request.reqId,
            TXN_TYPE: request.operation[TXN_TYPE],
            DATA: None
        }

        if txn:
            result[DATA] = txn.result
            result[f.SEQ_NO.nm] = get_seq_no(txn.result)

        self.transmitToClient(Reply(result), frm)
1293132
def parseLedgerForHaAndKeys(ledger, returnActive=True, ledger_size=None):
        
        nodeReg = OrderedDict()
        cliNodeReg = OrderedDict()
        nodeKeys = {}
        activeValidators = set()
        try:
            TxnStackManager._parse_pool_transaction_file(
                ledger, nodeReg, cliNodeReg, nodeKeys, activeValidators,
                ledger_size=ledger_size)
        except ValueError:
            errMsg = 'Pool transaction file corrupted. Rebuild pool transactions.'
            logger.exception(errMsg)
            exit(errMsg)

        if returnActive:
            allNodes = tuple(nodeReg.keys())
            for nodeName in allNodes:
                if nodeName not in activeValidators:
                    nodeReg.pop(nodeName, None)
                    cliNodeReg.pop(nodeName + CLIENT_STACK_SUFFIX, None)
                    nodeKeys.pop(nodeName, None)

            return nodeReg, cliNodeReg, nodeKeys
        else:
            return nodeReg, cliNodeReg, nodeKeys, activeValidators
1045928
public TempBlockMeta getTempBlockMeta(long blockId) throws BlockDoesNotExistException {
    TempBlockMeta blockMeta = getTempBlockMetaOrNull(blockId);
    if (blockMeta == null) {
      throw new BlockDoesNotExistException(ExceptionMessage.TEMP_BLOCK_META_NOT_FOUND, blockId);
    }
    return blockMeta;
  }
622403
public DeviceTokenEnvelope getDeviceToken(String deviceId) throws ApiException {
        ApiResponse<DeviceTokenEnvelope> resp = getDeviceTokenWithHttpInfo(deviceId);
        return resp.getData();
    }
942945
public static BaasResult<JsonObject> fetchDataSync(String id){
        if (id == null) throw new IllegalArgumentException("asset id cannot be null");
        BaasBox box = BaasBox.getDefaultChecked();
        AssetDataRequest req = new AssetDataRequest(box,id, RequestOptions.DEFAULT,null);
        return box.submitSync(req);
    }
1167126
public LockData getPendingLock(String nodeId)
   {
      if (pendingLocks.contains(nodeId))
      {
         return lockedNodes.get(nodeId);
      }
      else
      {
         return null;
      }
   }