Permalink
Browse files

Storing the pluginbundle's date/time of build

  • Loading branch information...
1 parent 82c9052 commit bfc372ee2024884428aeec5afed3dde199ab23de @rubendel rubendel committed Jan 5, 2017
Showing with 418 additions and 24 deletions.
  1. +0 −1 BimServer/.classpath
  2. +2 −0 BimServer/generated/org/bimserver/interfaces/SConverter.java
  3. +1 −0 BimServer/models/models.ecore
  4. +2 −0 BimServer/src/org/bimserver/BimServer.java
  5. +1 −1 BimServer/src/org/bimserver/database/Database.java
  6. +24 −0 BimServer/src/org/bimserver/database/actions/PluginBundleDatabaseAction.java
  7. +3 −3 BimServer/src/org/bimserver/database/actions/{UninstallPlugin.java → UninstallPluginBundle.java}
  8. +21 −0 BimServer/src/org/bimserver/database/migrations/steps/Step0028.java
  9. +2 −2 BimServer/src/org/bimserver/webservices/impl/PluginServiceImpl.java
  10. +0 −1 BimServerClientLib/.classpath
  11. +0 −1 BimServerWar/.classpath
  12. +17 −0 PluginBase/generated/org/bimserver/interfaces/objects/SPluginBundleVersion.java
  13. +28 −0 PluginBase/generated/org/bimserver/models/store/PluginBundleVersion.java
  14. +2 −1 PluginBase/generated/org/bimserver/models/store/PluginType.java
  15. +2 −2 PluginBase/generated/org/bimserver/models/store/SIPrefix.java
  16. +29 −1 PluginBase/generated/org/bimserver/models/store/StorePackage.java
  17. +20 −0 PluginBase/generated/org/bimserver/models/store/impl/PluginBundleVersionImpl.java
  18. +17 −6 PluginBase/generated/org/bimserver/models/store/impl/StorePackageImpl.java
  19. +1 −0 PluginBase/generated/org/bimserver/models/store/impl/store.ecore
  20. +206 −0 PluginBase/pluginbase.pom.xml
  21. +34 −2 PluginBase/src/org/bimserver/plugins/MavenPluginLocation.java
  22. +4 −1 Shared/src/org/bimserver/plugins/PluginManager.java
  23. +2 −2 Tests/pom.xml
@@ -15,7 +15,6 @@
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
- <attribute name="org.eclipse.jst.component.nondependency" value=""/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
@@ -10682,6 +10682,7 @@ public SPluginBundleVersion convertToSObject(PluginBundleVersion input) {
result.setIcon(input.getIcon());
result.setOrganization(input.getOrganization());
result.setName(input.getName());
+ result.setDate(input.getDate());
return result;
}
@@ -10717,6 +10718,7 @@ public PluginBundleVersion convertFromSObject(SPluginBundleVersion input, Plugin
result.setIcon(input.getIcon());
result.setOrganization(input.getOrganization());
result.setName(input.getName());
+ result.setDate(input.getDate());
return result;
}
public SPluginBundleType convertToSObject(PluginBundleType input) {
@@ -20583,6 +20583,7 @@
<eStructuralFeatures xsi:type="ecore:EAttribute" name="icon" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EByteArray"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="organization" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="date" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EDate"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EEnum" name="PluginBundleType">
<eLiterals name="MAVEN"/>
@@ -347,6 +347,7 @@ public long pluginBundleUpdated(PluginBundle pluginBundle) {
current.setVersion(sPluginBundleVersion.getVersion());
current.setOrganization(sPluginBundleVersion.getOrganization());
current.setName(sPluginBundleVersion.getName());
+ current.setDate(sPluginBundleVersion.getDate());
session.store(current);
@@ -546,6 +547,7 @@ public long pluginBundleInstalled(PluginBundle pluginBundle) {
pluginBundleVersion.setVersion(sPluginBundleVersion.getVersion());
pluginBundleVersion.setOrganization(sPluginBundleVersion.getOrganization());
pluginBundleVersion.setName(sPluginBundleVersion.getName());
+ pluginBundleVersion.setDate(sPluginBundleVersion.getDate());
session.commit();
return pluginBundleVersion.getOid();
@@ -92,7 +92,7 @@
* database-schema change. Do not change this variable when nothing has
* changed in the schema!
*/
- public static final int APPLICATION_SCHEMA_VERSION = 27;
+ public static final int APPLICATION_SCHEMA_VERSION = 28;
public Database(BimServer bimServer, Set<? extends EPackage> emfPackages, KeyValueStore keyValueStore, MetaDataManager metaDataManager) throws DatabaseInitException {
this.cidToEclass = new EClass[Short.MAX_VALUE];
@@ -1,8 +1,13 @@
package org.bimserver.database.actions;
+import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Properties;
import org.apache.maven.artifact.versioning.ArtifactVersion;
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
@@ -91,6 +96,25 @@ public SPluginBundle processMavenPluginLocation(MavenPluginLocation mavenPluginL
} catch (IOException e) {
LOGGER.error("", e);
}
+
+ try {
+ Path date = mavenPluginLocation.getVersionDate(mavenPluginVersion.getVersion().toString());
+ byte[] bytes = Files.readAllBytes(date);
+ Properties properties = new Properties();
+ properties.load(new ByteArrayInputStream(bytes));
+ String buildDateString = properties.getProperty("build.date");
+
+ DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
+ try {
+ sPluginBundleVersion.setDate(dateFormat.parse(buildDateString));
+ } catch (ParseException e) {
+// LOGGER.error("Invalid date format for plugin " + mavenPluginVersion.getModel().getName() + ": '" + buildDateString + "'");
+ }
+ } catch (ArtifactResolutionException e) {
+ // Not a problem
+ } catch (Exception e) {
+ LOGGER.error("", e);
+ }
}
}
}
@@ -11,16 +11,16 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class UninstallPlugin extends BimDatabaseAction<Void> {
+public class UninstallPluginBundle extends BimDatabaseAction<Void> {
- private static final Logger LOGGER = LoggerFactory.getLogger(UninstallPlugin.class);
+ private static final Logger LOGGER = LoggerFactory.getLogger(UninstallPluginBundle.class);
private BimServer bimServer;
private String groupId;
private String artifactId;
private String version;
private String repository;
- public UninstallPlugin(DatabaseSession databaseSession, AccessMethod accessMethod, BimServer bimServer, String repository, String groupId, String artifactId, String version) {
+ public UninstallPluginBundle(DatabaseSession databaseSession, AccessMethod accessMethod, BimServer bimServer, String repository, String groupId, String artifactId, String version) {
super(databaseSession, accessMethod);
this.bimServer = bimServer;
this.repository = repository;
@@ -0,0 +1,21 @@
+package org.bimserver.database.migrations.steps;
+
+import org.bimserver.database.DatabaseSession;
+import org.bimserver.database.migrations.Migration;
+import org.bimserver.database.migrations.Schema;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EcorePackage;
+
+public class Step0028 extends Migration {
+
+ @Override
+ public void migrate(Schema schema, DatabaseSession databaseSession) {
+ EClass pluginBundleVersion = schema.getEClass("store", "PluginBundleVersion");
+ schema.createEAttribute(pluginBundleVersion, "date", EcorePackage.eINSTANCE.getEDate());
+ }
+
+ @Override
+ public String getDescription() {
+ return "Add date field to PluginBundleVersion";
+ }
+}
@@ -77,7 +77,7 @@
import org.bimserver.database.actions.ListWebModulesDatabaseAction;
import org.bimserver.database.actions.SetPluginSettingsDatabaseAction;
import org.bimserver.database.actions.SetUserSettingDatabaseAction;
-import org.bimserver.database.actions.UninstallPlugin;
+import org.bimserver.database.actions.UninstallPluginBundle;
import org.bimserver.database.actions.UpdateDatabaseAction;
import org.bimserver.database.actions.UpdateDeserializerDatabaseAction;
import org.bimserver.database.actions.UpdateModelCompareDatabaseAction;
@@ -1515,7 +1515,7 @@ public void uninstallPluginBundle(String repository, String groupId, String arti
requireRealUserAuthentication();
DatabaseSession session = getBimServer().getDatabase().createSession();
try {
- session.executeAndCommitAction(new UninstallPlugin(session, getInternalAccessMethod(), getBimServer(), repository, groupId, artifactId, version));
+ session.executeAndCommitAction(new UninstallPluginBundle(session, getInternalAccessMethod(), getBimServer(), repository, groupId, artifactId, version));
} catch (Exception e) {
handleException(e);
} finally {
@@ -9,7 +9,6 @@
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
- <attribute name="org.eclipse.jst.component.nondependency" value=""/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
@@ -14,7 +14,6 @@
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
- <attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
@@ -16,6 +16,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see {@literal<http://www.gnu.org/licenses/>}.
*****************************************************************************/
+import java.util.Date;
import javax.xml.bind.annotation.XmlTransient;
import org.bimserver.shared.meta.*;
import javax.xml.bind.annotation.XmlRootElement;
@@ -39,6 +40,7 @@
private byte[] icon;
private java.lang.String organization;
private java.lang.String name;
+ private java.util.Date date;
public long getOid() {
return this.oid;
@@ -96,6 +98,9 @@ public Object sGet(SField sField) {
if (sField.getName().equals("name")) {
return getName();
}
+ if (sField.getName().equals("date")) {
+ return getDate();
+ }
if (sField.getName().equals("oid")) {
return getOid();
}
@@ -146,6 +151,10 @@ public void sSet(SField sField, Object val) {
setName((String)val);
return;
}
+ if (sField.getName().equals("date")) {
+ setDate((Date)val);
+ return;
+ }
if (sField.getName().equals("oid")) {
setOid((Long)val);
return;
@@ -237,6 +246,14 @@ public void setName(java.lang.String name) {
this.name = name;
}
+ public java.util.Date getDate() {
+ return date;
+ }
+
+ public void setDate(java.util.Date date) {
+ this.date = date;
+ }
+
@Override
public int hashCode() {
final int prime = 31;
@@ -16,6 +16,7 @@
*/
package org.bimserver.models.store;
+import java.util.Date;
import org.bimserver.emf.IdEObject;
/**
@@ -37,6 +38,7 @@
* <li>{@link org.bimserver.models.store.PluginBundleVersion#getIcon <em>Icon</em>}</li>
* <li>{@link org.bimserver.models.store.PluginBundleVersion#getOrganization <em>Organization</em>}</li>
* <li>{@link org.bimserver.models.store.PluginBundleVersion#getName <em>Name</em>}</li>
+ * <li>{@link org.bimserver.models.store.PluginBundleVersion#getDate <em>Date</em>}</li>
* </ul>
*
* @see org.bimserver.models.store.StorePackage#getPluginBundleVersion()
@@ -308,4 +310,30 @@
*/
void setName(String value);
+ /**
+ * Returns the value of the '<em><b>Date</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Date</em>' attribute isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Date</em>' attribute.
+ * @see #setDate(Date)
+ * @see org.bimserver.models.store.StorePackage#getPluginBundleVersion_Date()
+ * @model
+ * @generated
+ */
+ Date getDate();
+
+ /**
+ * Sets the value of the '{@link org.bimserver.models.store.PluginBundleVersion#getDate <em>Date</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>Date</em>' attribute.
+ * @see #getDate()
+ * @generated
+ */
+ void setDate(Date value);
+
} // PluginBundleVersion
@@ -303,7 +303,8 @@
* <!-- end-user-doc -->
* @generated
*/
- private static final PluginType[] VALUES_ARRAY = new PluginType[] { SERIALIZER, DESERIALIZER, RENDER_ENGINE, QUERY_ENGINE, OBJECT_IDM, WEB_MODULE, MODEL_MERGER, MODEL_COMPARE, MODEL_CHECKER, STILL_IMAGE_RENDER, SERVICE, };
+ private static final PluginType[] VALUES_ARRAY = new PluginType[] { SERIALIZER, DESERIALIZER, RENDER_ENGINE, QUERY_ENGINE, OBJECT_IDM, WEB_MODULE, MODEL_MERGER, MODEL_COMPARE, MODEL_CHECKER, STILL_IMAGE_RENDER,
+ SERVICE, };
/**
* A public read-only list of all the '<em><b>Plugin Type</b></em>' enumerators.
@@ -463,8 +463,8 @@
* <!-- end-user-doc -->
* @generated
*/
- private static final SIPrefix[] VALUES_ARRAY = new SIPrefix[] { METER, ATTOMETER, FEMTOMETER, PICOMETER, NANOMETER, MICROMETER, MILLIMETER, CENTIMETER, DECIMETER, DECAMETER, HECTOMETER, KILOMETER, MEGAMETER, GIGAMETER, TERAMETER,
- PETAMETER, EXAMETER, };
+ private static final SIPrefix[] VALUES_ARRAY = new SIPrefix[] { METER, ATTOMETER, FEMTOMETER, PICOMETER, NANOMETER, MICROMETER, MILLIMETER, CENTIMETER, DECIMETER, DECAMETER, HECTOMETER, KILOMETER, MEGAMETER,
+ GIGAMETER, TERAMETER, PETAMETER, EXAMETER, };
/**
* A public read-only list of all the '<em><b>SI Prefix</b></em>' enumerators.
@@ -6300,13 +6300,22 @@
int PLUGIN_BUNDLE_VERSION__NAME = 9;
/**
+ * The feature id for the '<em><b>Date</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ int PLUGIN_BUNDLE_VERSION__DATE = 10;
+
+ /**
* The number of structural features of the '<em>Plugin Bundle Version</em>' class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
* @ordered
*/
- int PLUGIN_BUNDLE_VERSION_FEATURE_COUNT = 10;
+ int PLUGIN_BUNDLE_VERSION_FEATURE_COUNT = 11;
/**
* The meta object id for the '{@link org.bimserver.models.store.impl.PluginBundleImpl <em>Plugin Bundle</em>}' class.
@@ -12940,6 +12949,17 @@
EAttribute getPluginBundleVersion_Name();
/**
+ * Returns the meta object for the attribute '{@link org.bimserver.models.store.PluginBundleVersion#getDate <em>Date</em>}'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the meta object for the attribute '<em>Date</em>'.
+ * @see org.bimserver.models.store.PluginBundleVersion#getDate()
+ * @see #getPluginBundleVersion()
+ * @generated
+ */
+ EAttribute getPluginBundleVersion_Date();
+
+ /**
* Returns the meta object for class '{@link org.bimserver.models.store.PluginBundle <em>Plugin Bundle</em>}'.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
@@ -18281,6 +18301,14 @@
EAttribute PLUGIN_BUNDLE_VERSION__NAME = eINSTANCE.getPluginBundleVersion_Name();
/**
+ * The meta object literal for the '<em><b>Date</b></em>' attribute feature.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ EAttribute PLUGIN_BUNDLE_VERSION__DATE = eINSTANCE.getPluginBundleVersion_Date();
+
+ /**
* The meta object literal for the '{@link org.bimserver.models.store.impl.PluginBundleImpl <em>Plugin Bundle</em>}' class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
@@ -16,6 +16,7 @@
*/
package org.bimserver.models.store.impl;
+import java.util.Date;
import org.bimserver.emf.IdEObjectImpl;
import org.bimserver.models.store.PluginBundleType;
@@ -42,6 +43,7 @@
* <li>{@link org.bimserver.models.store.impl.PluginBundleVersionImpl#getIcon <em>Icon</em>}</li>
* <li>{@link org.bimserver.models.store.impl.PluginBundleVersionImpl#getOrganization <em>Organization</em>}</li>
* <li>{@link org.bimserver.models.store.impl.PluginBundleVersionImpl#getName <em>Name</em>}</li>
+ * <li>{@link org.bimserver.models.store.impl.PluginBundleVersionImpl#getDate <em>Date</em>}</li>
* </ul>
*
* @generated
@@ -256,4 +258,22 @@ public void setName(String newName) {
eSet(StorePackage.Literals.PLUGIN_BUNDLE_VERSION__NAME, newName);
}
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public Date getDate() {
+ return (Date) eGet(StorePackage.Literals.PLUGIN_BUNDLE_VERSION__DATE, true);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void setDate(Date newDate) {
+ eSet(StorePackage.Literals.PLUGIN_BUNDLE_VERSION__DATE, newDate);
+ }
+
} //PluginBundleVersionImpl
Oops, something went wrong.

0 comments on commit bfc372e

Please sign in to comment.