Skip to content

Commit

Permalink
[guihttp] use guihttp workspace (#1311)
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasFey-GIP authored Dec 20, 2024
1 parent e2d6dce commit 95b9ac0
Show file tree
Hide file tree
Showing 17 changed files with 75 additions and 40 deletions.
2 changes: 1 addition & 1 deletion blackedition/blackedition_lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ ALL_DATAMODELTYPES=("mib","tr069","xsd");
#ACHTUNG: Version auch bei addRequirement zu default workspace berücksichtigen
ALL_APPLICATIONS="Base Processing"; #Default-Applications, die immer installiert sein sollten
APPMGMTVERSION=1.0.10
GUIHTTPVERSION=1.3.5
GUIHTTPVERSION=1.3.6
SNMPSTATVERSION=1.0.3
PROCESSINGVERSION=1.0.22
ALL_REPOSITORYACCESSES=("svn");
Expand Down
21 changes: 14 additions & 7 deletions installation/build/buildFilter.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,11 @@
<property file="${root.dir}/server.properties" />

<!-- depends on server make use of server variable -->
<property name="server.mdm.path" value="${server.path}/${revision.dir}/filter/${mdm.xml.name}" />
<property name="server.mdm.xml.path" value="${server.path}/${revision.dir}/saved/filter/${mdm.xml.name}" />
<property name="server.mdm.xml.filename" value="${mdm.xml.filename}" />
<property name="local.xml.dir" value="${basedir}/xmldefinition" />

<property name="deploy.sharedlibs" value=":" />
<pathconvert targetos="unix" property="deploy.jars">
<pathconvert targetos="unix" property="deploy.jars" pathsep=" ">
<path>
<pathelement location="./lib/${mdm.xml.name}.jar" />
<fileset dir="${basedir}/lib">
Expand All @@ -50,7 +48,6 @@

<map from="${basedir}/lib" to="${revision.dir}/filter/${mdm.xml.name}" />
</pathconvert>
<property name="deploy.template" value="addfilter -sharedLibs ${deploy.sharedlibs} -jarFiles ${deploy.jars} -triggerName ${trigger.name} -filterName ${filter.name} -workspaceName '${workspacename}' -fqClassName ${fqclassname}" />

<resolver:pom file="${basedir}/pom.xml" id="pom"/>

Expand Down Expand Up @@ -106,6 +103,16 @@
<!-- CAUTION: Do not attempt to launch this from here. Launch from build.xml instead. -->
<target name="deploy" depends="build" description="Deploy jar file to xyna server.">
<fail message="No server properties specified. Unable to deploy." unless="server.available" />
<local name ="revision" />
<local name = "revision.dir" />
<local name = "deploy.template" />
<local name = "server.mdm.xml.path" />
<determine-revision workspacename="${workspacename}" outputproperty="revision" />
<property name="revision.dir" value="../revisions/rev_${revision}" />
<property name="server.mdm.path" value="${server.path}/${revision.dir}/filter/${mdm.xml.name}" />
<property name="deploy.template" value="addfilter -sharedLibs ${deploy.sharedlibs} -jarFiles ${deploy.jars} -triggerName ${trigger.name} -filterName ${filter.name} -workspaceName '${workspacename}' -fqClassName ${fqclassname}" />
<property name="server.mdm.xml.path" value="${server.path}/${revision.dir}/saved/filter/${mdm.xml.name}" />

<!-- clean directory on xyna server -->
<!--<custom-ssh-exec host="${server.host}" username="${server.userid}" command="rm -rf ${server.mdm.path}" /> -->
<!-- create directory on xyna server -->
Expand All @@ -120,9 +127,9 @@
</then>
</if>
<!-- copy libraries and licences to xyna server -->
<custom-scp-to-remote fromdir="${target.dir}" frominclude="**/*" todir="${server.userid}@${server.host}:${server.mdm.path}" />
<!-- deploy datatype -->
<custom-ssh-exec host="${server.host}" username="${server.userid}" command="cd ${server.path}; ./xynafactory.sh ${deploy.template}" trust="true" />
<custom-scp-to-remote fromdir="${target.dir}" frominclude="**/*" todir="${server.mdm.path}" />
<!-- deploy filter -->
<custom-ssh-exec host="${server.host}" username="${server.userid}" command="cd ${server.path}; ./xynafactory.sh ${deploy.template}"/>
</target>

<!-- =================================
Expand Down
31 changes: 28 additions & 3 deletions installation/build/macros.xml
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,14 @@
<!-- exec into container -->
<isset property="server.containername" />
<then>
<exec executable="docker" failonerror="true">
<apply executable="docker">
<arg value="cp"/>
<arg value="@{fromdir}" />
<srcfile/>
<arg value="${server.containername}:@{todir}" />
</exec>
<fileset dir="@{fromdir}">
<include name="@{frominclude}" />
</fileset>
</apply>
</then>
<elseif>
<isset property="server.keyfile" />
Expand Down Expand Up @@ -326,4 +329,26 @@
</sequential>
</macrodef>

<!-- =================================
macro: determine-workspace-revision
================================= -->
<macrodef name="determine-revision">
<attribute name="workspacename" />
<attribute name="outputproperty" />
<sequential>
<local name="command" />
<if>
<matches pattern="^default workspace$" string="@{workspacename}"/>
<then>
<property name="command" value="cd ${server.path}; echo workingset" />
</then>
<else>
<property name="command" value="cd ${server.path}; ./xynafactory.sh printrevision -workspaceName '@{workspacename}'" />
</else>
</if>
<custom-ssh-exec host="${server.host}" username="${server.userid}" command="${command}" outputproperty="@{outputproperty}" />
<echo message="determined revision for '@{workspacename}' to be ${@{outputproperty}}" />
</sequential>
</macrodef>

</project>
2 changes: 1 addition & 1 deletion modules/xdev/yang/application.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
</RuntimeContextRequirement>
<RuntimeContextRequirement>
<ApplicationName>GuiHttp</ApplicationName>
<VersionName>1.3.5</VersionName>
<VersionName>1.3.6</VersionName>
</RuntimeContextRequirement>
</RuntimeContextRequirements>
</ApplicationInfo>
Expand Down
2 changes: 1 addition & 1 deletion modules/xmcp/gitIntegration/application.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<RuntimeContextRequirements>
<RuntimeContextRequirement>
<ApplicationName>GuiHttp</ApplicationName>
<VersionName>1.3.5</VersionName>
<VersionName>1.3.6</VersionName>
</RuntimeContextRequirement>
</RuntimeContextRequirements>
</ApplicationInfo>
Expand Down
2 changes: 1 addition & 1 deletion modules/xmcp/guihttp/application.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-->
<!-- ################# Version auch in blackedition_lib.sh updaten ########### -->
<Application applicationName="GuiHttp" comment="" factoryVersion="" versionName="1.3.5" xmlVersion="1.1">
<Application applicationName="GuiHttp" comment="" factoryVersion="" versionName="1.3.6" xmlVersion="1.1">
<ApplicationInfo>
<Description Lang="DE">GuiHTTPFilter</Description>
<Description Lang="EN">GuiHTTPFilter</Description>
Expand Down
2 changes: 2 additions & 0 deletions modules/xmcp/guihttp/filterimpl/H5XdevFilter/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@

<property name="trigger.name" value="Http" />
<property name="filter.name" value="H5XdevFilter" />

<property name="deploy.sharedlibs" value="XynaObjectJsonBuilder" />

<target name="prepareLibs" description="Prepare Libs">
<ant antfile="build.xml" target="build" inheritAll="false" dir="${basedir}/../../commonlib/HttpUtils">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public GeneralXynaObject execute(XynaPlainSessionCredentials creds, URLPath url,


private void addMetaTag(String sessionId, Long revision, URLPath url, String payload) throws Exception {
Long guiHttpRevision = Utils.getGuiHttpApplicationRevision();
Long guiHttpRevision = Utils.getGuiHttpRevision();
MetaTag metaTag = ((MetaTagRequest) Utils.convertJsonToGeneralXynaObject(payload, guiHttpRevision)).getMetaTag();
MetaTagProcessingInfoContainer data = MetaTagActionUtils.createProcessingInfoContainer(url, sessionId, xmomGui, revision);
String tag = metaTag.getTag();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ private String modelledOnResponse(GeneralXynaObject xo, HTTPTriggerConnection tc
long revision;
long backupRevision = -1L;
try {
revision = Utils.getGuiHttpApplicationRevision();
revision = Utils.getGuiHttpRevision();
backupRevision = XynaFactory.getInstance().getFactoryManagement().getXynaFactoryControl().getRevisionManagement().getRevision(rtc);
} catch (XNWH_OBJECT_NOT_FOUND_FOR_PRIMARY_KEY e) {
throw new RuntimeException(e);
Expand Down Expand Up @@ -170,7 +170,7 @@ private String modelledErrorResponse(XynaException[] xynaExceptions, HTTPTrigger
long guiHttpRevision = -1;
try {
orderRtc = Utils.getRtcRevision(rtc);
guiHttpRevision = Utils.getGuiHttpApplicationRevision();
guiHttpRevision = Utils.getGuiHttpRevision();
} catch (XNWH_OBJECT_NOT_FOUND_FOR_PRIMARY_KEY e) {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,10 @@ protected FilterActionInstance act(RuntimeContext rc, Long revision, URLPath url
}
RevisionManagement rm = XynaFactory.getInstance().getFactoryManagement().getXynaFactoryControl().getRevisionManagement();
Application app = (Application) rc;
Long calledRevision = rm.getRevision(app.getName(), app.getVersionName(), null);
Long calledRevision = rm.getRevision(app.getName(), app.getVersionName(), null);
boolean isApp = rm.isApplicationRevision(myRevision);


if (RevisionOrderControl.checkCustomOrderEntryClosed(calledRevision, myRevision, H5XdevFilter.ORDERENTRYNAME)) {
if (isApp && RevisionOrderControl.checkCustomOrderEntryClosed(calledRevision, myRevision, H5XdevFilter.ORDERENTRYNAME)) {
AuthUtils.replyError(tc, jfai, Status.forbidden, new RuntimeException("Order entry disabled for application '" + app.getName() + "/" + app.getVersionName() + "'."));
return jfai;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,7 @@ public FilterActionInstance act(URLPath url, HTTPTriggerConnection tc) throws Xy

CreateUserRequest createUserRequest = (CreateUserRequest) com.gip.xyna.xact.filter.util.Utils.convertJsonToGeneralXynaObject(
tc.getPayload(),
com.gip.xyna.xact.filter.util.Utils.getRtcRevision(
com.gip.xyna.xact.filter.util.Utils.getGuiHttpApplication()
));
com.gip.xyna.xact.filter.util.Utils.getGuiHttpRevision());
String passwordHashed = PasswordCreationUtils.generatePassword(createUserRequest.getPassword(), EncryptionPhase.LOGIN);
boolean success = factoryManagement.createUser(createUserRequest.getUsername(), createUserRequest.getRole(), passwordHashed, true, createUserRequest.getDomains());
jfai.sendJson(tc, "{\"success\": " + (success ? "true" : "false") + "}");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,7 @@ public FilterActionInstance act(URLPath url, HTTPTriggerConnection tc) throws Xy

UpdateUserRequest updateUserRequest = (UpdateUserRequest) com.gip.xyna.xact.filter.util.Utils.convertJsonToGeneralXynaObject(
tc.getPayload(),
com.gip.xyna.xact.filter.util.Utils.getRtcRevision(
com.gip.xyna.xact.filter.util.Utils.getGuiHttpApplication()
));
com.gip.xyna.xact.filter.util.Utils.getGuiHttpRevision());

User user = factoryManagement.getUser(updateUserRequest.getUsername());
if(user == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -541,13 +541,18 @@ private void createJsonForLeafElement(JsonBuilder jsonBuilder, Step step, AVaria


private void writePrunedValue(JsonBuilder builder, String instanceId) {
Application app = Utils.getGuiHttpApplication();
com.gip.xyna.xfmg.xfctrl.revisionmgmt.RuntimeContext rtc = Utils.getGuiHttpRtc();
PrunedValue prunedValue = new PrunedValue.Builder().message("Value was pruned by LazyLoading. Id was " + instanceId).instance();
builder.addObjectAttribute(XynaObjectVisitor.META_TAG);
builder.addStringAttribute(MetaInfo.FULL_QUALIFIED_NAME, prunedValue.getClass().getCanonicalName());
builder.addObjectAttribute(MetaInfo.RUNTIME_CONTEXT);
builder.addStringAttribute(RuntimeContextVisitor.APPLICATION_LABEL, app.getName());
builder.addStringAttribute(RuntimeContextVisitor.VERSION_LABEL, app.getVersionName());
if(rtc instanceof Application) {
Application casted = (Application)rtc;
builder.addStringAttribute(RuntimeContextVisitor.APPLICATION_LABEL, casted.getName());
builder.addStringAttribute(RuntimeContextVisitor.VERSION_LABEL, casted.getVersionName());
} else {
builder.addStringAttribute(RuntimeContextVisitor.WORKSPACE_LABEL, rtc.getName());
}
builder.endObject();
builder.endObject();
builder.addStringAttribute("message", prunedValue.getMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
import com.gip.xyna.xact.filter.session.cache.CachedXynaObjectVisitor;
import com.gip.xyna.xact.filter.session.cache.JsonBuilderCache;
import com.gip.xyna.xact.filter.session.cache.JsonVisitorCache;
import com.gip.xyna.xact.filter.session.exceptions.RevisionNotFoundException;
import com.gip.xyna.xact.filter.session.gb.StepMap;
import com.gip.xyna.xact.filter.session.gb.StepMap.RecursiveVisitor;
import com.gip.xyna.xact.filter.util.xo.GenericResult;
Expand Down Expand Up @@ -126,17 +125,20 @@ public static Integer getOperationIndex(Operation operation) {
return null;
}

public static Application getGuiHttpApplication() {
public static RuntimeContext getGuiHttpRtc() {
ApplicationManagementImpl am = (ApplicationManagementImpl)XynaFactory.getInstance().getFactoryManagement().getXynaFactoryControl().getApplicationManagement();
String highestRunningVersion = am.getHighestVersion(APP_NAME, true);
if(highestRunningVersion == null) {
return new Workspace(APP_NAME);
}
return new Application(APP_NAME, highestRunningVersion);
}

public static String xoToJson(GeneralXynaObject generalXynaObject) {
try {
return xoToJson(generalXynaObject, getGuiHttpApplicationRevision());
return xoToJson(generalXynaObject, getGuiHttpRevision());
} catch (XNWH_OBJECT_NOT_FOUND_FOR_PRIMARY_KEY e) {
throw new RevisionNotFoundException(Utils.getGuiHttpApplication());
throw new RuntimeException(e);
}
}

Expand Down Expand Up @@ -202,7 +204,7 @@ public static xprc.xpce.RuntimeContext getXpceRtc(RuntimeContext revisionmgmtRtc
public static GeneralXynaObject convertJsonToGeneralXynaObjectUsingGuiHttp(String json) {
long revision = -1;
try {
revision = com.gip.xyna.xact.filter.util.Utils.getRtcRevision(com.gip.xyna.xact.filter.util.Utils.getGuiHttpApplication());
revision = Utils.getGuiHttpRevision();
} catch (XNWH_OBJECT_NOT_FOUND_FOR_PRIMARY_KEY e) {
throw new RuntimeException(e.getMessage(), e);
}
Expand Down Expand Up @@ -308,8 +310,8 @@ private static void appendException(StringBuilder sb, Throwable throwable) {
}
}

public static Long getGuiHttpApplicationRevision() throws XNWH_OBJECT_NOT_FOUND_FOR_PRIMARY_KEY {
return revisionManagement.getRevision(getGuiHttpApplication());
public static Long getGuiHttpRevision() throws XNWH_OBJECT_NOT_FOUND_FOR_PRIMARY_KEY {
return revisionManagement.getRevision(getGuiHttpRtc());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public static void writeMetaData(JsonBuilder jb, String fqn, boolean includeRtc)


private static RuntimeContextJson getRtcXmomContainers() {
return new RuntimeContextJson(Utils.getGuiHttpApplication());
return new RuntimeContextJson(Utils.getGuiHttpRtc());
}


Expand Down
2 changes: 0 additions & 2 deletions modules/xmcp/guihttp/workspace.properties

This file was deleted.

2 changes: 1 addition & 1 deletion modules/xmcp/xypilot/application.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<RuntimeContextRequirements>
<RuntimeContextRequirement>
<ApplicationName>GuiHttp</ApplicationName>
<VersionName>1.3.5</VersionName>
<VersionName>1.3.6</VersionName>
</RuntimeContextRequirement>
<RuntimeContextRequirement>
<ApplicationName>XyPilotMetricsDefaults</ApplicationName>
Expand Down

0 comments on commit 95b9ac0

Please sign in to comment.