Gets the object generation for a Write operation

@param resourceId object for which generation info is requested
@return the generation of the object
@throws IOException if the object already exists and cannot be overwritten
189187
private long getWriteGeneration(StorageResourceId resourceId, boolean overwritable)
      throws IOException {
    logger.atFine().log("getWriteGeneration(%s, %s)", resourceId, overwritable);
    GoogleCloudStorageItemInfo info = getItemInfo(resourceId);
    if (!info.exists()) {
      return 0L;
    }
    if (info.exists() && overwritable) {
      long generation = info.getContentGeneration();
      Preconditions.checkState(generation != 0, "Generation should not be 0 for an existing item");
      return generation;
    }
    throw new FileAlreadyExistsException(String.format("Object %s already exists.", resourceId));
  }
710928
public <T extends MPBase> T getById(String id) throws MPException {
        T resource = null;
        for (int i = 0; i < _resourceArray.size(); i++) {
            resource = getByIndex(i);
            try {
                Field field = resource.getClass().getDeclaredField("id");
                field.setAccessible(true);
                String resourceId = field.get(resource).toString();
                if (resourceId.equals(id)) {
                    break;
                }
            } catch (Exception exception) {
                throw new MPException(exception);
            }
        }
        return resource;
    }
309605
public static Interface get(nitro_service service, String id) throws Exception{
		Interface obj = new Interface();
		obj.set_id(id);
		Interface response = (Interface) obj.get_resource(service);
		return response;
	}
1056470
WritableByteChannel createInternal(URI path, CreateFileOptions options)
      throws IOException {

    // Validate the given path. false == do not allow empty object name.
    StorageResourceId resourceId = pathCodec.validatePathAndGetId(path, false);
    if (options.getExistingGenerationId() != StorageResourceId.UNKNOWN_GENERATION_ID) {
      resourceId = new StorageResourceId(
          resourceId.getBucketName(),
          resourceId.getObjectName(),
          options.getExistingGenerationId());
    }
    WritableByteChannel channel = gcs.create(resourceId, objectOptionsFromFileOptions(options));
    tryUpdateTimestampsForParentDirectories(ImmutableList.of(path), ImmutableList.<URI>of());
    return channel;
  }
1059328
@Override
  protected String generateActivityInstanceId(String activityId) {

    if (activityId.equals(processDefinitionId)) {
      return processInstanceId;

    } else {

      String nextId = Context.getProcessEngineConfiguration().getIdGenerator().getNextId();

      String compositeId = activityId + ":" + nextId;
      if (compositeId.length() > 64) {
        return String.valueOf(nextId);
      } else {
        return compositeId;
      }
    }
  }
1009923
public static ResourceRequest getUnitResourceRequest(ResourceType type) {
    ResourceRequest req = unitResourceRequestMap.get(type);
    if (req == null) {
      req = new ResourceRequest(1, type);
      req.setSpecs(UNIT_COMPUTE_SPECS);

      // instead of using concurrent classes or locking - we clone and replace
      // the map with a new entry. this makes sense because this structure is
      // entirely read-only and will be populated quickly at bootstrap time

      HashMap<ResourceType, ResourceRequest> newMap =
          new HashMap<ResourceType, ResourceRequest>();
      for (Map.Entry<ResourceType, ResourceRequest> entry :
          unitResourceRequestMap.entrySet()) {
        newMap.put(entry.getKey(), entry.getValue());
      }
      newMap.put(type, req);
      unitResourceRequestMap = newMap;
    }
    return req;
  }
1293411
public static StorageResourceId fromObjectName(String objectName, long generationId) {
    Matcher matcher = OBJECT_NAME_IN_GCS_PATTERN.matcher(objectName);
    checkArgument(matcher.matches(), "'%s' is not a valid GCS object name.", objectName);

    String bucketName = matcher.group(2);
    String relativePath = matcher.group(4);
    if (bucketName == null) {
      checkArgument(generationId == UNKNOWN_GENERATION_ID,
          "Cannot specify generationId '%s' for root object '%s'", generationId, objectName);
      return ROOT;
    } else if (relativePath != null) {
      return new StorageResourceId(bucketName, relativePath, generationId);
    }
    checkArgument(generationId == UNKNOWN_GENERATION_ID,
        "Cannot specify generationId '%s' for bucket '%s'", generationId, objectName);
    return new StorageResourceId(bucketName);
  }
370669
private void writeResources() throws IOException
   {
      writeAttributeTypes("resource_types", ResourceField.values());

      m_writer.writeStartList("resources");
      for (Resource resource : m_projectFile.getResources())
      {
         writeFields(null, resource, ResourceField.values());
      }
      m_writer.writeEndList();
   }
875221
public void write(@NonNull Resource resource) throws IOException {
      try (JsonWriter writer = Json.createWriter(resource)) {
         writer.beginDocument();
         writer.property("id", getId());
         writer.property("content", toString());

         if (attributes.size() > 0) {
            writer.beginObject("attributes");
            for (Map.Entry<AttributeType, Val> entry : attributeEntrySet()) {
               writer.property(entry.getKey().name(), entry.getKey().getValueType().encode(entry.getValue()));
            }
            writer.endObject();
         }

         if (annotationSet.size() > 0) {
            writer.beginObject("completed");
            for (AnnotatableType type : getAnnotationSet().getCompleted()) {
               writer.property(type.canonicalName(), getAnnotationSet().getAnnotationProvider(type));
            }
            writer.endObject();

            writer.beginArray("annotations");
            for (Annotation annotation : annotationSet) {
               writer.beginObject();
               writer.property("type", annotation.getType().name());
               writer.property("start", annotation.start());
               writer.property("end", annotation.end());
               writer.property("id", annotation.getId());
               if (Config.get("Annotation.writeContent").asBooleanValue(false)) {
                  writer.property("content", annotation.toString());
               }

               if (annotation.getAttributeMap().size() > 0) {
                  writer.beginObject("attributes");
                  for (Map.Entry<AttributeType, Val> entry : annotation.attributeEntrySet()) {
                     writer.property(entry.getKey().name(),
                                     entry.getKey().getValueType().encode(entry.getValue()));

                  }
                  writer.endObject();
               }

               Collection<Relation> relations = annotation.relations();
               if (relations.size() > 0) {
                  writer.beginArray("relations");
                  for (Relation relation : relations) {
                     writer.beginObject();
                     writer.property("type", relation.getType());
                     writer.property("value", relation.getValue());
                     writer.property("target", relation.getTarget());
                     writer.endObject();
                  }
                  writer.endArray();
               }

               writer.endObject();
            }
            writer.endArray();
         }
         writer.endDocument();
      }
   }
935619
public static hanode get(nitro_service service, Long id) throws Exception{
		hanode obj = new hanode();
		obj.set_id(id);
		hanode response = (hanode) obj.get_resource(service);
		return response;
	}
119267
public void setResourceId(String resourceId) {

        try {
            if (!m_type.isFolder()) {
                m_resourceId = new CmsUUID(resourceId);
            } else {
                m_resourceId = new CmsUUID();
            }
        } catch (Throwable e) {
            setThrowable(e);
        }
    }
708704
public static int getId(Context context, String id, String defType) {
        String type = "R." + defType + ".";
        if (id.startsWith(type)) {
            id = id.substring(type.length());
        }

        Resources r = context.getResources();
        int resId = r.getIdentifier(id, defType,
                context.getPackageName());
        if (resId > 0) {
            return resId;
        } else {
            throw new RuntimeAssertion("Specified resource '%s' could not be found", id);
        }
    }
262327
protected ObjectId readObjectId() throws IOException {
		int time = ByteOrderUtil.flip(_in.readInt());
		int machine = ByteOrderUtil.flip(_in.readInt());
		int inc = ByteOrderUtil.flip(_in.readInt());
		return new ObjectId(time, machine, inc);
	}
780184
private Response writeResource(final String method, final String body) throws IOException {
		buildQueryString();
		buildHeaders();

		connection.setDoOutput(true);
		connection.setRequestMethod(method);

		writer = new OutputStreamWriter(connection.getOutputStream());
		writer.write(body);
		writer.close();

		return readResponse();
	}
875827
async def get_instance(self, resource_id) -> ApiResource:
        """"""
        raw = await self.get_resource(resource_id)
        return self._resource_factory(self._get_to_actual_data(raw))
1297707
public PrintWriter getContentWriter(String id) {
        try {
            OutputStream out = new FileOutputStream(getLogFile(id));
            Writer writer = new OutputStreamWriter(out, "UTF-8");
            return new PrintWriter(writer, true);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
1039147
public static GoogleCloudStorageItemInfo createInferredDirectory(StorageResourceId resourceId) {
    checkArgument(resourceId != null, "resourceId must not be null");
    return new GoogleCloudStorageItemInfo(
        resourceId,
        /* creationTime= */ 0,
        /* size= */ 0,
        /* location= */ null,
        /* storageClass= */ null);
  }