th_biedermann
Occasional Collector

Error in method invocation: Method getStore(java.lang.String) not found in class'de.espirit.firstsp

Hallo zusammen

Ich habe folgendes Script (finden von nicht verwendeten Medien) bei dem ich aber probleme habe.

Scheinbar passt die Zeile 6 nicht, weiss aber nicht wie ich das anpassen muss. Hat mir jemand einen Tipp

SCRIPT:

import de.espirit.firstspirit.access.project.Project;
import de.espirit.firstspirit.access.store.mediastore.Media;
import de.espirit.firstspirit.access.store.Store;

Project project = context.getProject();
Store mediaStore = project.getStore("Media");

PictureResolution resolution = project.getResolutionByName("ORIGINAL");

int zaehler = 1;

for (Media medium : mediaStore.getEntities(Media.class, true)) {
    try {
        if (medium.getIncomingReferences().isEmpty()) {
            long size = 0;

            if (medium.getType() == Media.FILE) {
                size = medium.getFile(project.getMasterLanguage()).getSize();
            } else if (medium.getType() == Media.PICTURE) {
                Picture picture = medium.getPicture(project.getMasterLanguage());
                if (picture != null) {
                    size = picture.getPictureResolution(resolution).getSize();
                }
            }

            print("Nicht referenziertes Medium " + zaehler + ": " + medium.getUid() + " (ID=" + medium.getId() + "), (Größe =" + size + " Bytes)");
            zaehler++;
        }
    } catch (Exception e) {
        context.logError("Exception:", e);
    }
}

 

FEHLER:

de.espirit.firstspirit.access.script.ExecutionException: Typed variable declaration : Error in method invocation: Method getStore(java.lang.String) not found in class'de.espirit.firstspirit.server.projectmanagement.ProjectImpl' : at Line: 6 : in file: inline evaluation of: ``__execute() { import de.espirit.firstspirit.access.project.Project; import de.es . . . '' : project .getStore ( "Media" ) 

Called from method: __execute at line 6
	at de.espirit.firstspirit.server.script.BeanshellScriptEngine$BeanshellExecutable.execute(BeanshellScriptEngine.java:111)
	at de.espirit.firstspirit.server.script.PermissionsScriptEngine$PermissionsExecutable.lambda$execute$1(PermissionsScriptEngine.java:85)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at de.espirit.firstspirit.server.script.PermissionsScriptEngine$PermissionsExecutable.execute(PermissionsScriptEngine.java:90)
	at de.espirit.firstspirit.server.script.PermissionsScriptEngine$PermissionsExecutable.execute(PermissionsScriptEngine.java:85)
	at de.espirit.firstspirit.client.gui.applications.ApplicationTabRegistry$IdentifiableExecutable.execute(ApplicationTabRegistry.java:116)
	at de.espirit.firstspirit.common.ScriptUtil.execute(ScriptUtil.java:111)
	at de.espirit.firstspirit.common.ScriptUtil.executePrivileged(ScriptUtil.java:164)
	at de.espirit.firstspirit.common.ScriptUtil$2.run(ScriptUtil.java:151)
	at de.espirit.firstspirit.client.gui.util.GuiUtil$RunnableWrapper.run(GuiUtil.java:1968)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.base/java.lang.Thread.run(Unknown Source)
Caused by: bsh.EvalError: Typed variable declaration : Error in method invocation: Method getStore(java.lang.String) not found in class'de.espirit.firstspirit.server.projectmanagement.ProjectImpl' : at Line: 6 : in file: inline evaluation of: ``__execute() { import de.espirit.firstspirit.access.project.Project; import de.es . . . '' : project .getStore ( "Media" ) 

Called from method: __execute
	at bsh.BSHMethodInvocation.eval(BSHMethodInvocation.java:78)
	at bsh.BSHPrimaryExpression.eval(BSHPrimaryExpression.java:102)
	at bsh.BSHPrimaryExpression.eval(BSHPrimaryExpression.java:47)
	at bsh.BSHVariableDeclarator.eval(BSHVariableDeclarator.java:86)
	at bsh.BSHTypedVariableDeclaration.eval(BSHTypedVariableDeclaration.java:84)
	at bsh.BSHBlock.evalBlock(BSHBlock.java:130)
	at bsh.BSHBlock.eval(BSHBlock.java:80)
	at bsh.BshMethod.invokeImpl(BshMethod.java:371)
	at bsh.BshMethod.invoke(BshMethod.java:267)
	at bsh.BshMethod.invoke(BshMethod.java:170)
	at bsh.PreparsedScript.invoke(PreparsedScript.java:66)
	at de.espirit.firstspirit.server.script.BeanshellScriptEngine$BeanshellExecutable.execute(BeanshellScriptEngine.java:100)
	... 12 more
Caused by: bsh.ReflectError: Method getStore(java.lang.String) not found in class'de.espirit.firstspirit.server.projectmanagement.ProjectImpl'
	at bsh.Reflect.resolveExpectedJavaMethod(Reflect.java:414)
	at bsh.Reflect.invokeObjectMethod(Reflect.java:116)
	at bsh.Name.invokeMethod(Name.java:858)
	at bsh.BSHMethodInvocation.eval(BSHMethodInvocation.java:75)

 

Grüsse. Thomas

0 Kudos
1 Reply
Windmüller
Crownpeak employee

Die API-Klasse Project hat keine Methode "getStore". Stattdessen kannst Du Dir über das Project den UserService holen und dort getStore aufrufen.

0 Kudos