All Downloads are FREE. Search and download functionalities are using the official Maven repository.

scripts.1.4.0.2-create-archived-app.js Maven / Gradle / Ivy

There is a newer version: 4.5.2
Show newest version
var subAppIds = [];
var allAppIds = [];

db.subscriptions.find({},{application: 1}).forEach(
  function(sub) {
    subAppIds.push(sub.application);
  }
);

db.applications.find({}, {_id: 1}).forEach(
  function(app) {
    allAppIds.push(app._id);
  }
);

now = new Date();
subAppIds.forEach(
  function (appId) {
    if (allAppIds.indexOf(appId) === -1) {
      db.applications.insertOne(
        {
          _id: appId,
          _class : "io.gravitee.repository.mongodb.management.internal.model.ApplicationMongo",
          name: "Archived App",
          description: "Archived application created in version 1.4.0",
          status: "ARCHIVED",
          createdAt: now,
          updatedAt: now
        }
      );

      /*
        Applications must have a PRIMARY_OWNER member. 
        Fill the `userId` attribute with the one you choose.
        Choose the Administration by defaut.
       */
      db.memberships.insertOne(
        {
          _id : {
            userId : "Fill with the user ID",
            referenceId : appId,
            referenceType : "APPLICATION"
          },
          _class : "io.gravitee.repository.mongodb.management.internal.model.MembershipMongo",
          type : "PRIMARY_OWNER",
          createdAt : now,
          updatedAt : now
        }
      );
    }
  }
);




© 2015 - 2024 Weber Informatics LLC | Privacy Policy